Hi
I'm encountering some problems with some simple Code I've copied from someone, I'm just using my variables (field names) in stead of the author's.
I'm really new to this too so please be patient. I welcome any responses.
I'm trying to auto populate the form as soon as you select the first name from the combo box. If I do this I get an error. "Compile error: Invalid qualifier"
Here is the code:
"Option Compare Database
Private Sub Name_AfterUpdate() -->(this becomes highlighted yellow)
On Error Resume Next
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Name.SetFocus -->(this becomes highlighted grey)
If Name.Value > 0 Then
strSQL = "SELECT * FROM Table1 WHERE ID = " & Name.Value
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
If Not rs.BOF Then
Me.ID = rs("ID")
Me.IDNumber = rs("IDNumber")
Me.Sex = rs("Sex")
Me.Resident = rs("Resident")
Me.Salary = rs("Salary")
Me.Date = rs("Date")
Me.Surname = rs("Surname")
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End If
End Sub"
Well if i didn't give enough info or if I didn't explain correclty, please say.
Thanks a lot.
I'm encountering some problems with some simple Code I've copied from someone, I'm just using my variables (field names) in stead of the author's.
I'm really new to this too so please be patient. I welcome any responses.
I'm trying to auto populate the form as soon as you select the first name from the combo box. If I do this I get an error. "Compile error: Invalid qualifier"
Here is the code:
"Option Compare Database
Private Sub Name_AfterUpdate() -->(this becomes highlighted yellow)
On Error Resume Next
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Name.SetFocus -->(this becomes highlighted grey)
If Name.Value > 0 Then
strSQL = "SELECT * FROM Table1 WHERE ID = " & Name.Value
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)
If Not rs.BOF Then
Me.ID = rs("ID")
Me.IDNumber = rs("IDNumber")
Me.Sex = rs("Sex")
Me.Resident = rs("Resident")
Me.Salary = rs("Salary")
Me.Date = rs("Date")
Me.Surname = rs("Surname")
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End If
End Sub"
Well if i didn't give enough info or if I didn't explain correclty, please say.
Thanks a lot.