Gregorys05
Board Regular
- Joined
- Sep 24, 2008
- Messages
- 217
Hi All,
I have the below code that i am trying to referance a query within a Dlookup, now the code works fine when i enter the name of the query into the dlookup(Instead of the SQL) but when using the SQL variable it dosn't recognise that its a query what do i have to do for the Dlookup to recognise it??
Thanks
I have the below code that i am trying to referance a query within a Dlookup, now the code works fine when i enter the name of the query into the dlookup(Instead of the SQL) but when using the SQL variable it dosn't recognise that its a query what do i have to do for the Dlookup to recognise it??
Thanks
Code:
Private Sub Add_Click()
Dim VersionName As String
Dim SQL As String
VersionName = Forms!Replace!NewImageaddress & "V1"
SQL = "SELECT tblreplace.fldScanName FROM tblreplace WHERE (((tblreplace.fldScanName = " & VersionName & "));"
If DLookup(1, SQL, True) Then
MsgBox "Value there"
Else
MsgBox "Not There"
End If
End Sub