Help!!Please! with RecordsetClone.Next

Madison123

Registered User.
Local time
Today, 14:11
Joined
Dec 16, 2010
Messages
10
My user enters a value into a text box and selects search. The first record matching this value is returned. However I want the user to be able to continue selecting search and keep hitting records with this value untill the end. Can anyone help? im pretty new to this so any help people can offer would be great.. Below is the code I have and seems to be working fine but I just need to add in the RecordsetClone.Next function somehwere and it just does not seem to work for me..

Private Sub Search_Click() 'Searching
DoCmd.Requery

Set rst = Me.RecordsetClone ' new code
rst.FindFirst "[TRCSNNumber] = '" & Me![SN] & "' or[SerialNumber2] = '" & Me![SN] & "' or[SerialNumber3] = '" & Me![SN] & "' "
DoCmd.RunMacro "DateAndTime"

If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = rst.Bookmark
Else
MsgBox " The Number you have entered cannot be Found"

End If
Criteria
End Sub
 
Change FindFirst to FindNext.

Also replace Me.RecordsetClone.NoMatch with rst.NoMatch
 
Thanks for the fast reply. I just tried that and the search function just stopped working altogether. I kept getting my Msg Box saying the number is not there.

Any other ideas? Thanks again!
 
Remove the DoCmd.Requery line. Why did you put it?
What does the DateAndTime macro do?
 
Figured it out! The macro was to insert the date and Time of the last time the record was modified.. Turned out though that included Viewed so was useless.. thats my next task.. but for now I got it working, thanks a million!



Dim message
Set RST = Me.RecordsetClone ' new code

RST.FindNext "[TRCSNNumber] = '" & Me![SN] & "' or[SerialNumber2] = '" & Me![SN] & "' or[SerialNumber3] = '" & Me![SN] & "' "


If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = RST.Bookmark
Else
message = MSGBOX("No more Records with this serial Number could be found", vbOKOnly)

End If

End Sub
 
Again, Me.RecordsetClone.NoMatch is incorrect. As mentioned before, change it to rst.NoMatch. You are not performing a FindFirst on the form's recordset, you are performing on the rst object.
 
Thank you for all your help! I was wondering could someone advise me on error handling. All My application is doing is inserting information into one table. And viewing this information. Again I am new to this so sorry if i sound silly!


View Information code--

Private Sub FindNext_Click()

Dim message
Set rst = Me.RecordsetClone ' new code

rst.FindNext "[TRCSNNumber] = '" & Me![SN] & "' or[SerialNumber2] = '" & Me![SN] & "' or[SerialNumber3] = '" & Me![SN] & "' "


If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
Else
message = MSGBOX("No more Records with this serial Number could be found", vbOKOnly)

End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom