Well I hope I'm not misunderstanding the question, but this is what I think you can do...
[The following code is for Access 2000. In Access 97, you must use version 3.51 of the Jet Engine]
Dim conn As Connection
Dim rst As Recordset
Dim DatabasePath As String
Set conn = CreateObject("ADODB.Connection")
Set rst = CreateObject("ADODB.Recordset")
DatabasePath = "C:\db1.mdb"
'Open the connection to your database
conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" & DatabasePath
rst.ActiveConnection = conn
'Open the recordset using a simple SQL statement
rst.Open "SELECT [studentno] FROM [TableName]", , adOpenDynamic, adLockOptimistic
'Loop through the recordset to grab all the student numbers
Do Until rst.EOF
cboBox.AddItem rst.Fields("studentno")
rst.MoveNext
Loop
'Now that you have all the student numbers in the combobox, you can use SQL to grab the rest of the data
rst.Open "SELECT * FROM [TableName] WHERE [studentno]=" & cboBox.Text
If you have any more questions, don't hesitate to ask. And if I'm wrong about something, correct me (it's been a while) =]
Good Luck
Enter your message below
Sign in or Join us (it's free).