Re: Form creates new record! Why?
- From: "Brian Bastl" <bastl@xxxxxxxxxxx>
- Date: Thu, 9 Feb 2006 08:21:10 -0500
Tony,
Your search form should be unbound, meaning that it has no record source.
The second option is to add an unbound combo to the Header in frmContacts
(using the Wizard) and select the option to "Find a record on my form based
on the value I selected in my combo box".
HTH,
Brian
"Tony Williams" <tw@xxxxxxxxxxx> wrote in message
news:u36S73VLGHA.3100@xxxxxxxxxxxxxxxxxxxxxxx
I have created a simple find form. It has one control which is a combo box
based on a field (txtsurname) in my table (tblcontacts). I have a command
button that when the user has selected the surname of the record they want
to find opens up a form (frmcontacts). However when the form opens to show
the records it also adds a new record with the same name. Why is this
happening?
The code behind the OnClick event of the command button is
Private Sub Command2_Click()
On Error GoTo Command2_Click_Err
Dim stLinkCriteria As String
stLinkCriteria = "[txtsurname]=" & "'" & Me![txtSurname] & "'"
If IsNull(DLookup("[txtsurname]", "tblContacts", stLinkCriteria)) Then
MsgBox "There is no Contact with this Surname.", _
vbInformation, "No Matching Record"
Else
DoCmd.OpenForm "frmContacts", , , "[txtSurname]=" & "'" &
Me![txtSurname] & "'"
End If
Command2_Click_Exit:
Exit Sub
Command2_Click_Err:
Response = acDataErrContinue
Resume Command2_Click_Exit
End Sub
Thank you
Tony
.
- Follow-Ups:
- Re: Form creates new record! Why?
- From: Tony Williams
- Re: Form creates new record! Why?
- References:
- Form creates new record! Why?
- From: Tony Williams
- Form creates new record! Why?
- Prev by Date: Re: database open control
- Next by Date: Re: Form creates new record! Why?
- Previous by thread: Form creates new record! Why?
- Next by thread: Re: Form creates new record! Why?
- Index(es):