Opening 1 form from 2 forms
Hi all,
Please can someone help. I need to open a form "frmViewContact", with a preselected record in it from 2 buttons, each on a different form.
frmA has cmdViewContact (criteria from a combobox, cboContactID)
frmB has cmdViewContact (criteria from a combobox, cboContactID)
Here is my so far incorrect code.
Each button has a Click Event Procedure:
Private Sub cmdViewContact_Click() *** on frmCalls ***
Dim strContact As String
strContact = "SELECT mtblContacts.*, mtblContacts.idsContactID FROM mtblContacts " _
& " WHERE ((mtblContacts.idsContactID) Like [Forms]![frmCalls]![cboContactID])"
DoCmd.OpenForm "frmViewContact"
With Forms!frmViewContact
.SetFocus
.RecordSource = strContact
.Requery
End With
End Sub
AND
Private Sub cmdViewContact_Click() *** on frmTransactions ***
Dim strContact As String
strContact = "SELECT mtblContacts.*, mtblContacts.idsContactID FROM mtblContacts " _
& " WHERE ((mtblContacts.idsContactID) Like [Forms]![frmTransactions]![cboContactID])"
DoCmd.OpenForm "frmViewContact"
With Forms!frmViewContact
.SetFocus
.RecordSource = strContact
.Requery
End With
End Sub
The idea is to set the RecordSource for frmViewContact in code. How do I pass the parameter directly to this form depending on which button I access it from? At the moment it the little parameter input dialog comes up (I don't want that) and I have a SubForm on frmViewContact which only shows if I manually fill in the parameter input dialog.
I hope this all makes sense. Please help. Any help is greatly appreciated.
Thank you in advance,
Clinton
|