Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Feb 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Have a subform with a combo box on a main form. In some instances, with selection of combo box on subform, I want to copy field content from subform to main form text boxes. The first field of subform (folder_print) "SO" copies to main form (tbl_scanned) but will not switch back to subform with .SETFOCUS to copy
    content of field "CU". The .SETFOCUS to mainform appears to work correctly

    Private Sub Combo8_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[SO] = '" & Me![Combo8] & "'"
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark

    DoCmd.GoToControl "SO"
    DoCmd.RunCommand acCmdCopy
    Forms!tbl_scanned!Text16.SetFocus
    DoCmd.RunCommand acCmdPaste
    Forms!Folder_Print!CU.SetFocus
    DoCmd.RunCommand acCmdCopy
    Forms!tbl_scanned!Text18.SetFocus
    DoCmd.RunCommand acCmdPaste

  2. #2
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Not sure why you need to use Copy and Paste.
    You could just have the data placed directly into the appropriate control

    Here is the General Syntax.....

    Edited AW ....
    IF you want to get data into a Main form Control from a field on the Subform

    [Main Form Control] = [Subform Name].Form![Sub Form Control]

    NOTE.... Subform name is the name of the SubForm Control which may not be the same as the actual Sub Form

    IF YOU ARE ON A SUB FORM and want Data from a Main Form Control in a Sub Form Control

    [Subform Control Name]=Parent![Main Form Control Name]
    Andrew

  3. #3
    Star Lounger
    Join Date
    Feb 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Want to pull 4 fields from subform to main form. Your two examples both pull from main to sub, just varying which form has focus. Is syntax different moving data from sub to main?

  4. #4
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Apologies the wording on one of mine was misleading.
    I have corrected it, BUT also here is more to show how to PUT data into a Field on the Main Form whilst on the Sub Form

    Suppose the Sub Form Combo is changed
    and you want to put data from a SubForm Control into a Control on the Main Form

    Then the Code would be something like

    Parent![Main Form Control name] = [Sub Form Control Name]

    In this case you should not need to reference the subform, because the field controls are already on it.
    Since the Main form fields are NOT on the sub form you should be able to reference them just using the Parent Object
    Andrew

  5. #5
    Star Lounger
    Join Date
    Feb 2006
    Posts
    71
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you Andrew. Parent![Main Form Control name] = [Sub Form Control Name] was the command
    I was looking for.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •