retrive record from combo box

A

Ac

Hi,

I created a combo box named cboStudentID on the form fStudents, I would like
to select a studentID from the cboStudentID, and retrieves the corresponding
record from the Students table and displays in the form fStudents. Now the
cboStudentID picks up studentID, studentName, curEmployer from the Students
table and Bound Column is 1 (StudentID), it is works well. But after I made
the selection from the cboStudentID, no records displayed in the form, what
is wrong? Please help me. Thanks!

Here is the code for cboStudentID:

Private Sub cboStudentID_AfterUpdate()
‘Form Record Source
Me.RecordSource = "Select * from Students Where StudentID = " +
CStr(Me!cboStudentID)


End Sub
 
B

Beetle

Try this;

Private Sub cboStudentID_AfterUpdate()

With Me.RecordsetClone
.FindFirst "[StudentID]=" & Me.cboStudentID
If Not .NoMatch Then
Me.Bookmark = .Bookmark
Else
Msgbox "No Record Found"
End If
End With

End Sub
_________

Sean Bailey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top