Hi Guys and Lassies,
Currently creating a program and need one bit of info to complete.
Using really simple code (Not SQL) I want to select a name from a dropdown combo, and once selected, displays the name in a label, AS WELL as displaying relevant info from a database table in two other labels (ie The database has columns name, age and telephone number. I click on the name from a dropdown and the form displays name age and telephone number on the form)

Can someone please reply. I would really appreciate your expert help on this.


try this

'this is using DAO 3.6 object library and access 2003
Dim db As Database
Dim rs As Recordset

Private Sub cmbnm_Click()
If cmbnm.Text <> "" Then
If rs.RecordCount > 0 Then
rs.Index = "nm"
rs.Seek "=", Trim(cmbnm.Text)
If rs.NoMatch = False Then
lblage.Caption = rs!age
lblphone.Caption = rs!phone
End If
End If
MsgBox "Please select from combox first", vbInformation, "error"

End If

End Sub

Private Sub Form_Load()
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2

Set db = OpenDatabase(App.Path & "\db1.mdb")

End Sub

Private Sub loadname()
Set rs = db.OpenRecordset("table1")
If rs.RecordCount > 0 Then
Do While rs.EOF <> True
cmbnm.AddItem Trim(rs!Name)

MsgBox "No records found", vbInformation, "Error"
End If
End Sub