I have a VBA code below, but every time when I try to execute the VBA code it gives me error on [Dlookup] I spent hours and hours trying to get the Dlookup right, but no luck. Appreciate if you can have a look of it and provide me with some insights or solutions. Thanks.
Sub Quality()
Dim Sql As String
StrDate = InputBox("YYYY/MM/DD")
Sql = "Insert Into Roster_QC Select dbo_Recipients.[UniqueID] AS [UID],
DLookUp("[Address1]", "dbo_NamesAndAddresses", "[PersonID]=' " & [UID] & " ' AND [PrimaryAddress]=1" ) AS [Address]…FROM…
WHERE…ORDER BY
CurrentDb.Execute Sql
DoCmd.OpenReport "RosterQC_Report", View:=acViewPreview
End Sub
Also, I have changed the Dlookup as of below
DLookUp(""[Address1]"", ""dbo_NamesAndAddresses"", ""[PersonID]='" & [UID] & "' AND [PrimaryAddress]=1"" ) AS Address
This give rise to error - [UID] External Name not defined.
Me!UID.Value
. – Gustav