Hello,
My application requires that data entry people check to see if a contact already exists in the database before entering a new "contact log" incident.
I have created six search forms, each based on a separate parameter query. For example, the data entry person can begin by searching on "town" to see if there are any existing contacts from a particular town.
The search form works well. It displays every contact living in a town that corresponds to what the data entry person keystroked into the parameter dialog box.
The next step is for the data entry person to select a contact by clicking on the contact's ID, and then to click on my "Open Contact Log" command button.
The following code, attached to the button's "On Click" event opens the proper form and displays a record wherein the contact ID matches the one found in the search form:
Code:
Private Sub cmdOpenContactLog_Click()
On Error GoTo Err_cmdOpenContactLog_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmContactServicesLog"
stLinkCriteria = "[VictimID]=" & Me![VictimID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Me![VictimID].SetFocus
DoCmd.Close acForm, Me.Name
Exit_cmdOpenContactLog_Click:
Exit Sub
Err_cmdOpenContactLog_Click:
MsgBox Err.Description
Resume Exit_cmdOpenContactLog_Click
End Sub
However, I need for the Contact form to open in a New Record, and to do so with the contact ID already populated with the contact ID selected in the search form.
When I add a "DoCmd.GoToRecord, , acNewRecord" line, the Contact form opens in a new record, but the contact ID field is blank.
How can I get the form to open in a new record and have the contact ID field match the contact ID field selected in the search form?
Thanks for all your help.
George M. Fodor