Hi everyone,
I'm having a problem needing to pull out a record that may be in one of many, unrelated tables. I'm have a union query set up that lists all of the IDs in all of the tables and have DoCmd.OpenForm code that will check to see if the ID is in the table then open the form that belongs to the appropriate table. However, I'm having trouble opening the form to the correct record. As of now, the form opens to the record that was first entered.
Notes: ID is the ID that could be in any of the tables
Option# represents the possible tables
Optoin#FRM represents the form that is associated with the option# table
Do you think this is a good way of searching through all of the tables, or should I write another query? If this method works, what am I doing wrong in the argument statement for the DoCmd.Openform?
Let me know if you need more specifics or have any questions! Thanks in advance for the help!
I'm having a problem needing to pull out a record that may be in one of many, unrelated tables. I'm have a union query set up that lists all of the IDs in all of the tables and have DoCmd.OpenForm code that will check to see if the ID is in the table then open the form that belongs to the appropriate table. However, I'm having trouble opening the form to the correct record. As of now, the form opens to the record that was first entered.
PHP:
Private Sub Combo4_AfterUpdate()
If DCount("ID", "[Option1]", "[ID] = '" & Me.Combo4 & "'") > 0 Then
DoCmd.OpenForm "Option1FRM", , , , acFormEdit, , " & Me.Combo4 & " '"
ElseIf DCount("ID", "[Option2]", "[ID] = '" & Me.Combo4 & "'") > 0 Then
DoCmd.OpenForm "Option2FRM", , , , acFormEdit, , " & Me.Combo4 & " '"
ElseIf DCount("ID", "[Option3]", "[ID] = '" & Me.Combo4 & "'") > 0 Then
DoCmd.OpenForm "Option3FRM", , , , acFormEdit, , " & Me.Combo4 & " '"
End If
DoCmd.Close acForm, "Contact_Edit_Select_Frm"
End Sub
Option# represents the possible tables
Optoin#FRM represents the form that is associated with the option# table
Do you think this is a good way of searching through all of the tables, or should I write another query? If this method works, what am I doing wrong in the argument statement for the DoCmd.Openform?
Let me know if you need more specifics or have any questions! Thanks in advance for the help!