I am trying to create a search function which would allow the user to scroll through the records in the program based on their status in the yes/no checkbox. I have developed to the point where it will scroll to the first record with a 'no' status, but it will go no further.
Ok ... a check box will return a value of True (-1), False (0), or if it is unbound and has the triple state property set to yes, then a Null can be returned as well (I recommend setting the Triple State property to no ...
The DoCmd object acts upon the object with the focus, so if you use the .FindRecord method, you will probably want to set the focus to the field (control) that you wish to search through since .FindRecord has the option to search ALL fields, or just the "current" field, which is the one that has the Focus. So, your code should look something like this ...
Code:
Private Sub SomeCommanButtonName_Click()
Me.SomeControlName.SetFocus
DoCmd.FindRecord Me.UnBoundCheckBoxControlName, acAnywhere, , , , acCurrent
End Sub
With the said, and the limitations around the DoCmd object, I would suggest that you do NOT use DoCmd.FindRecord. I would suggest you utilitize the forms RecordsetClone property and the DAO object models' .FindNext menthod (there is a FindFirst, FindPrevious, FindLast also, and they all have the same syntax structure)
Code:
Private Sub SomeCommandButton_Click()
With Me.RecordsetClone
.FindFirst "YourYesNoField = " & Me.UnBoundCheckBoxName
If .NoMatch Then
MsgBox "Not Found"
Else
Me.Bookmark = .Bookmark
End If
End With
End Sub
By using the DAO & RecordsetClone technique, you do not have to be concerned about which control has the focus, plus you gain a ton of flexibility with your search.
Hope that helps!
>> Edits <<
Sorry ... I had this post "In the Que" for a LONG time .. so .. I missed the middle part of the "conversation" ..
Rural Guy,
Yes, they can scroll through all records but, I want them to be able to scroll through only the records in the yes/no checkbox which reads no.
CoachPhil