Update form

C

CF

I have a form with multiple combo boxes, list boxes, and
check boxes. I tried this a different way but I couldn't
get it to work. If I can get this to work maybe I can use
it to revert to my orginal planning. So what I am trying
to do is have a combo box with the customers name with id
in column 0. Once the user select the name from the combo
box it should bring in all their and update each
criteria. Here is my code so far.

Private Sub cboSID_Change()
Dim dbs As Database
Dim rst As Recordset
Dim strFound As String, strCriteria As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblStudentData",
dbOpenDynaset)
strCriteria = "StudentIDNumber=" & Me!cboSID.Column(0)
rst.FindFirst strCriteria
strFound = rst.Bookmark
If rst.NoMatch Then
MsgBox "Record not found"
Else
rst.Bookmark = strFound
End If
rst.Close
End Sub

Could someone possibly point me in the right direction? I
would appreciate, thanks
 
M

Marshall Barton

CF said:
I have a form with multiple combo boxes, list boxes, and
check boxes. I tried this a different way but I couldn't
get it to work. If I can get this to work maybe I can use
it to revert to my orginal planning. So what I am trying
to do is have a combo box with the customers name with id
in column 0. Once the user select the name from the combo
box it should bring in all their and update each
criteria. Here is my code so far.

Private Sub cboSID_Change()
Dim dbs As Database
Dim rst As Recordset
Dim strFound As String, strCriteria As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblStudentData",
dbOpenDynaset)
strCriteria = "StudentIDNumber=" & Me!cboSID.Column(0)
rst.FindFirst strCriteria
strFound = rst.Bookmark
If rst.NoMatch Then
MsgBox "Record not found"
Else
rst.Bookmark = strFound
End If
rst.Close
End Sub


Sorry, but I don't understand what you mean by " it should
bring in all their and update each criteria".

If you want the form to move to the record identified by the
FindFirst, then I don't see a problem with your code. But,
you should not be using the Change event for this. The
change event fires for each keystroke in the combo box, use
the AfterUpdate event instead.

One thing that can really mess over this kind of situation
is to make sure that the combo box is unbound (its control
source must be blank).

What happens when you use your code?
 

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