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
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