GaelicFatboy
Registered User.
- Local time
- Today, 21:07
- Joined
- Apr 17, 2007
- Messages
- 100
I’m looking to write a common piece of code to get data from a table using the following code:
Private Sub MySub_DataFind(My_TblQry As String, My_Field As String, My_Control As String)
Dim My_RecordSet As DAO.Recordset, My_DataBase As DAO.Database
Dim My_test As String
Set My_DataBase = CurrentDb
et My_RecordSet = My_DataBase.OpenRecordset(My_TblQry, dbOpenForwardOnly) With My_RecordSet
Me.Controls(My_Control) = ![My_Field] 'this is where it doesn’t work
.Close
End With
End Sub
Normally I would type the field name between the square brackets “[ ]” but for the sub routine to work the field name will vary. I’m not getting the syntax right can anyone help?
Cheers
D
Private Sub MySub_DataFind(My_TblQry As String, My_Field As String, My_Control As String)
Dim My_RecordSet As DAO.Recordset, My_DataBase As DAO.Database
Dim My_test As String
Set My_DataBase = CurrentDb
et My_RecordSet = My_DataBase.OpenRecordset(My_TblQry, dbOpenForwardOnly) With My_RecordSet
Me.Controls(My_Control) = ![My_Field] 'this is where it doesn’t work
.Close
End With
End Sub
Normally I would type the field name between the square brackets “[ ]” but for the sub routine to work the field name will vary. I’m not getting the syntax right can anyone help?
Cheers
D