Query creating duplicate record

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
 
T

Tony Williams

Sorry guys solved the problem I used the command button wizard and it gave
me what I wanted.
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top