Moving to Empty Field in RecordsetClone

Ruth

Registered User.
Local time
Today, 15:22
Joined
Jan 28, 2009
Messages
16
This should be easy...

On opening a continuous form for editing existing records, I want the cursor to land on the first record without a specific field filled in, so that the user can update the field without having to scroll down to it.

It appears that the code below is moving all the way through the recordset, since for example, if the query brings up 3 records, I get the message box 3 times. My problem is that it isn't updating the criteria for evaluating each record (it moves through each record with the criteria from the first), and always leaves my cursor on the first record no matter what.

What am I missing to get it to re-evaluate the criteria as it moves through the recordset? Here's the code:

Code:
Private Sub Form_Load()
Dim rs As Recordset
Set rs = Me.RecordsetClone
rs.MoveFirst
Me!Sent_to_CFacO_Date.SetFocus
Do While Not rs.EOF
    If (Me!Sent_to_CFacO_Date) <> "" Then
            rs.MoveNext
            Me!Sent_to_CFacO_Date.SetFocus
            MsgBox "Sent_to_CFacO_Date" & Me!Sent_to_CFacO_Date
    Else
           Exit Do
    End If
Loop
rs.Close
Set rs = Nothing
End Sub

Thank you!
 
two things -

First -

Change this:
If (Me!Sent_to_CFacO_Date) <> "" Then

to this:
If Len(Me!Sent_to_CFacO_Date & "") <> 0 Then


Second -

you need to set

Me.Bookmark = rs.Bookmark

once you've found the location.
 
Wow! That worked perfectly. Thank you so much. Ruth
 

Users who are viewing this thread

Back
Top Bottom