Getting it to loop

PharmaFun

New member
Local time
Today, 12:33
Joined
Jul 30, 2003
Messages
5
Hello,

I have a code for AfterUpdate, but in my combobox, only when the first number in the list is selected are the fields "Initials", "DOB", etc. are filled. I've tried putting in a "rs.MoveNext" at the end of the loop, but that doesn't help.

Ideas?

Thanks,
Dino

Private Sub cboSearchID_AfterUpdate()
' Find the record that matches the control.
Dim rs As DAO.Recordset, SQL As String
Set rs = Me.Recordset.Clone

SQL = "SELECT * FROM [Initial Report] order by [Number];"
Set rs = CurrentDb.OpenRecordset(SQL)
rs.MoveFirst
Do While Not rs.EOF

If rs("Number") = Me.cboSearchID Then
Me.Initials = rs("Initials")
Me.DOB = rs("DOB")
Me.Gender = rs("Gender")
Me.Ethnicity = rs("Ethnicity")
Me.Doctor = rs("Doctor")
Else
Me.Initials = Null
Me.DOB = Null
Me.Gender = Null
Me.Ethnicity = Null
Me.Doctor = Null
Me.Number = Null
End If

Me.Number = Me.cboSearchID
Me.cboSearchID = Null

Exit Do
Loop
rs.Close
Set rs = Nothing
Set rs = CurrentDb.OpenRecordset(SQL)

End Sub
 
Me.Number = Me.cboSearchID
Me.cboSearchID = Null
rs.movenext <<<<Add This
Exit Do <<<take this out
Loop
 

Users who are viewing this thread

Back
Top Bottom