Hi everybody
I'm a total access/vba novice and looking for some advice on how to populate a number of text box controls on an access form with data from a table.
There will be around 15 fields that I need to be auto populated once the user has entered a member number.
I can get this to work using dlookup but it is a bit slow and through my research its seems that dlookup is not preferred?
I have tried to use the following code:
Private Sub Command7_Click()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * FROM dbo_MemberMain WHERE [MemberNo] = Me.[memberNo]")
Me.[Forename] = rs!Forename
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
I tested the query through the query designer and it works but when I come to click the button on the form nothing happens. The code complies but doesn’t seem to do anything.
Like I said I am a total vba novice so the above may be total rubbish
Any advice would be most welcome.
I'm a total access/vba novice and looking for some advice on how to populate a number of text box controls on an access form with data from a table.
There will be around 15 fields that I need to be auto populated once the user has entered a member number.
I can get this to work using dlookup but it is a bit slow and through my research its seems that dlookup is not preferred?
I have tried to use the following code:
Private Sub Command7_Click()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Select * FROM dbo_MemberMain WHERE [MemberNo] = Me.[memberNo]")
Me.[Forename] = rs!Forename
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
I tested the query through the query designer and it works but when I come to click the button on the form nothing happens. The code complies but doesn’t seem to do anything.
Like I said I am a total vba novice so the above may be total rubbish
Any advice would be most welcome.