So I created a code that is working on itself, but when I try to make it "parameterizable" so I can call it multiple times it doesn't.
Here is the code:
and the I call it like this:
So I should be able to put every object from my form in there and the matching table field.
When I put Me.BH_Check and Product_BH in the code itself it works. So probably something is wrong with the data types of the user defined variables. But I don't know what it should be then?
Here is the code:
Code:
Public Sub CurrentRecordMacro(MyObject As Object, TableField As Object)
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblProductSpecs")
rst.MoveFirst
Do Until rst.EOF
If rst("Project Nr") = Me.Project_Text Then
MyObject = rst!TableField
End If
rst.MoveNext
Loop
End Sub
Code:
CurrentRecordMacro Me.BH_Check, Product_BH
When I put Me.BH_Check and Product_BH in the code itself it works. So probably something is wrong with the data types of the user defined variables. But I don't know what it should be then?