Results 1 to 6 of 6
  1. #1
    LMA is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2013
    Posts
    7

    Combobox to open a form to selected record

    I've created a few different forms to aid users in updating information and a selection form with a combobox to open the appropriate form for the ID# selected from the combobox using the following code:



    Private Sub Command14_Click()
    If Me.FormSelection = "General_Cal" Then
    strForm = "frmCalibrationGeneral"
    ElseIf Me.FormSelection = "Caliper_6in" Then
    strForm = "frmCalibrationCaliper6in"
    ElseIf Me.FormSelection = "Micrometer_1in" Then
    strForm = "frmCalibrationMicrometer1in"
    ElseIf Me.FormSelection = "Universal_Cal" Then
    strForm = "frmCalibrationUniversal"
    ElseIf Me.FormSelection = "ForceGage_50Lbs" Then
    strForm = "frmCalibrationForceGage50Lbs"
    ElseIf Me.FormSelection = "Go_NoGo" Then
    strForm = "frmCalibrationGoNoGo"
    End If
    DoCmd.OpenForm strForm
    End Sub

    While the code works and opens the correct form, the ID# has to be selected again in the combobox on the form. Is there a way to open the form to the record chosen from the selection form?

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    If [ID#] is Numeric

    DoCmd.OpenForm strForm, , , "[ID#] =" & Me.ControlHoldingID

    If [ID#] is Text

    DoCmd.OpenForm strForm, , , "[ID#] ='" & Me.ControlHoldingID & "'"

    You'll need to replace ControlHoldingID with the actual name of the Control, on the first Form, where the ID# is located.

    Using this method, you will only be able to work with the targeted Record in the secondary Form.

    A different method would be needed if you wanted to be able to work with the targeted Record in the secondary Form and then go to other Records in that Form.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    LMA is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2013
    Posts
    7
    I entered this code:
    DoCmd.OpenForm strForm, , , "[Combo49] ='" & Me.Combo5 & "'"

    Combo5 is on the selection form and combo49 is on the second form.
    When I tried this a message box: Enter Parameter Value would appear. Entering in an ID# or not made no difference. The second form ID would be blank as usual. And I tried with/without the brackets on combo49.

    I am new at this so I may be overlooking something.

    Your last comment is something I’ve thought about but would need to limit the record selection to only those that would use that particular form. It would make it more convenient for repeated use.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I believe that [Combo49] needs to be replaced with the name of the Field that [Combo49] is Bound to, in the second Form.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    LMA is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2013
    Posts
    7
    Ah, yes, now I got it! Combo49 was unbound. Changed it to Bound to the ID and now it works!

    THANKS

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 09-20-2012, 11:09 AM
  2. Replies: 1
    Last Post: 05-31-2012, 01:01 PM
  3. Replies: 7
    Last Post: 05-01-2012, 11:43 AM
  4. Replies: 1
    Last Post: 03-31-2011, 12:18 PM
  5. Replies: 9
    Last Post: 12-18-2010, 12:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums