Hi guys, I'm having a trouble when using DLOOKUP function and combine it together in the SELECT clause of an SQL expression, i wonder if this is actually possible to be done, and if so, I would appreciate help from you, because I can't come up with the correct syntax to make this work.
I'm doing it this way, because some of the registers in the table "tblBobins" do not have any "IDMachine" assigned, and when opening a recordset using INNER JOIN to bring in the other table, it excludes the registers that do not have it.
If there is any better way to achieve so, I'll be happy to learn from you guys. I'm still learning about VBA.
Thanks in advance for your help.
I'm doing it this way, because some of the registers in the table "tblBobins" do not have any "IDMachine" assigned, and when opening a recordset using INNER JOIN to bring in the other table, it excludes the registers that do not have it.
Code:
Dim SQLB as String
SQLB = "SELECT tblBobins.IDBobin, IIF(NOT ISNULL([tblBobins]![IDMachine_FK]), DLookup('MachineNumber', 'tblMachines', 'IDMachine = [tblBobins]![IDMachine_FK]'), '') AS [Machine] FROM tblBobins"
Set rsBobins = CurrentDb.OpenRecordset(SQLB, dbOpenDynaset)
If there is any better way to achieve so, I'll be happy to learn from you guys. I'm still learning about VBA.
Thanks in advance for your help.