cool thnx that works.
wish to expand to find next record
but wont except rs.findnext
Private Sub comboCustRef_AfterUpdate() 'search for cust ref
On Error GoTo Err_ComboCustRef 'on error
Dim rs As DAO.Recordset
txtCustID.SetFocus 'set focus
If Not IsNull(Me.comboCustRef) Then 'Search in the clone set
Set rs = Me.RecordsetClone
If Me.txtCustID = Me.comboCustRef Then 'if combo is same -
search for next record
rs.FindNext '!!!!!!!!!!!!!HERE IS THE PROBLEM?!?
If rs.NoMatch Then 'no record found
MsgBox "There are no more records for this school name."
End If
Else
rs.FindFirst "[txtCustID] = " & Me.comboCustRef 'search
records
If rs.NoMatch Then 'no record found
MsgBox "There is no record for this school, please check
and
try again."
Else
Me.Bookmark = rs.Bookmark 'Display the found record
in
the form.
End If
End If
Set rs = Nothing
End If
Exit_ComboCustRef: 'error handling
Exit Sub
Err_ComboCustRef:
MsgBox Err.Description
Resume Exit_ComboCustRef
End Sub
--
thanks
liz
Allen Browne said:
Instead of FindRecord, use FindFirst on the RecordsetClone of the form.
You
can then test its NoMatch property to see if it found a result or not.
Here's an example:
Using a Combo Box to Find Records
at:
http://allenbrowne.com/ser-03.html
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
liz said:
using code to search for a string
however not sure what to do if it doesnt find it
eg.
[txtCustName].setfocus
DoCmd.FindRecord comboCustName
If the customers name cannot be found i want to display a message
box.....but not sure how to (eg. If comboCustName Not found Then
MsgBox)