I am trying to on event click in a listbox to populate the fields on my form. I have made each field unbound and I am trying to use this code.
Private Sub lstLabName_Click()
Set rs = db.OpenRecordset("SELECT * FROM tblLabratory WHERE tblLabratory.LabratoryID = '" & Me.lstLabName & "'"
rs.MoveFirst
Me.txtLabID.Text = rs("LabratoryID"
Me.txtLabratoryName.Text = rs("LabratoryName"
Me.txtContactName.Text = rs("LabContactName"
Me.txtContactPhone.Text = rs("LabContactPhone"
Me.txtAddress.Text = rs("LabAddress"
Me.txtCity.Text = rs("LabCity"
Me.cboStateProv.Text = rs("LabState"
Me.txtZip.Text = rs("LabZip"
Me.txtNotes.Text = rs("LabNotes"
rs.Close
End Sub
I get this runtime error "3464"
datatype mismatch in criteria expression
The LabID is an autonumber in the database. The listbox query's the table and populates LabID and Lab Name. When I run the code the me.lstLabName = LabID then produces the error.
Any suggestions?
thx in advance
Mychal
Private Sub lstLabName_Click()
Set rs = db.OpenRecordset("SELECT * FROM tblLabratory WHERE tblLabratory.LabratoryID = '" & Me.lstLabName & "'"
rs.MoveFirst
Me.txtLabID.Text = rs("LabratoryID"
Me.txtLabratoryName.Text = rs("LabratoryName"
Me.txtContactName.Text = rs("LabContactName"
Me.txtContactPhone.Text = rs("LabContactPhone"
Me.txtAddress.Text = rs("LabAddress"
Me.txtCity.Text = rs("LabCity"
Me.cboStateProv.Text = rs("LabState"
Me.txtZip.Text = rs("LabZip"
Me.txtNotes.Text = rs("LabNotes"
rs.Close
End Sub
I get this runtime error "3464"
datatype mismatch in criteria expression
The LabID is an autonumber in the database. The listbox query's the table and populates LabID and Lab Name. When I run the code the me.lstLabName = LabID then produces the error.
Any suggestions?
thx in advance
Mychal