Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FindFirst, NoMatch Problem

Status
Not open for further replies.

jedrtd

Programmer
Jul 22, 2001
23
US
I have a form that is being use to update a file, I placed an unbound control on it and will use this to look for the record to update. It founds the record if it is there fine, but if nomatch I want it to ret to the seach field. I put this code in the afterupdate event of the search field

Private Sub List48_AfterUpdate()
On Error GoTo Err_Go_To_List48_AfterUpdate
' Find the record that matches the control.
Dim rs As Object
Dim ctl As Control

Set ctl = Forms![Postage Stamp Log Return]!List48

Set rs = Me.Recordset.Clone
rs.FindFirst "[Roll Number] = " & Str(Me![List48])
If rs.NoMatch Then
Me.Bookmark = rs.Bookmark
Forms![Postage Stamp Log Return]!List48.SetFocus
MsgBox "No entry found"

Exit Sub
Else
Me.Bookmark = rs.Bookmark
[Qty Returened].SetFocus
Exit Sub
End If


Exit_Go_To_List48_AfterUdate:
Exit Sub

Err_Go_To_List48_AfterUpdate:
MsgBox Err.Description
Resume Exit_Go_To_List48_AfterUdate

End Sub

it is not working, It was working sometime, but the more I fool around with it the worst it get. Could someone please help me.


Thanks
 
Hi jedrtd,

There are a few things, one is why are you setting a bookmark if there is no record found? Try using something like the code below.



Private Sub List48_AfterUpdate()
On Error GoTo Err_Go_To_List48_AfterUpdate
' Find the record that matches the control.
Dim rs As Recordset
Dim ctl As Control
Dim strcriteria as String

Set ctl = Forms![Postage Stamp Log Return]!List48
Set rs = Me.RecordsetClone
strcriteria = "[Roll Number] = " & Str(Me![List48])

rs.FindFirst strcriteria
If rs.NoMatch Then
ctl.SetFocus
MsgBox "No entry found"
Exit Sub
Else
Me.Bookmark = rs.Bookmark
[Qty Returened].SetFocus [red]<-- Is Returned spelled like this in your DB?[/red]
Exit Sub
End If


Exit_Go_To_List48_AfterUdate:
Exit Sub

Err_Go_To_List48_AfterUpdate:
MsgBox Err.Description
Resume Exit_Go_To_List48_AfterUdate

End Sub
Regards,
gkprogrammer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top