T
Tony Williams
I have a Find Record form with a combo box and a command button that opens a
form for the relevant record
The OnClick procedure is
Private Sub Command2_Click()
On Error GoTo Command2_Click_Err
Dim stLinkCriteria As String
stLinkCriteria = "[txtinstitution]=" & "'" & Me![txtInstitution] & "'"
If IsNull(DLookup("[txtinstitution]", "tblMDi", stLinkCriteria)) Then
MsgBox "There is no Institution/Person with this name.", _
vbInformation, "No Matching Record"
Else
DoCmd.OpenForm "frmMDi", , , "[txtinstitution]=" & "'" &
Me![txtInstitution] & "'"
End If
Command2_Click_Exit:
Exit Sub
Command2_Click_Err:
Response = acDataErrContinue
Resume Command2_Click_Exit
End Sub
The control source of the combo box is TxtInstitution and the Row Source is
SELECT tblMDI.txtInstitution FROM tblMDI GROUP BY tblMDI.txtInstitution
ORDER BY tblMDI.txtInstitution;
But when I select a record and the form opens I also get a duplicate record
created. What am I doing wrong here?
Thanks
Tony
form for the relevant record
The OnClick procedure is
Private Sub Command2_Click()
On Error GoTo Command2_Click_Err
Dim stLinkCriteria As String
stLinkCriteria = "[txtinstitution]=" & "'" & Me![txtInstitution] & "'"
If IsNull(DLookup("[txtinstitution]", "tblMDi", stLinkCriteria)) Then
MsgBox "There is no Institution/Person with this name.", _
vbInformation, "No Matching Record"
Else
DoCmd.OpenForm "frmMDi", , , "[txtinstitution]=" & "'" &
Me![txtInstitution] & "'"
End If
Command2_Click_Exit:
Exit Sub
Command2_Click_Err:
Response = acDataErrContinue
Resume Command2_Click_Exit
End Sub
The control source of the combo box is TxtInstitution and the Row Source is
SELECT tblMDI.txtInstitution FROM tblMDI GROUP BY tblMDI.txtInstitution
ORDER BY tblMDI.txtInstitution;
But when I select a record and the form opens I also get a duplicate record
created. What am I doing wrong here?
Thanks
Tony