Hi Everyone, I'm struggling with creating a string that's being used to create a query.
Couple of quick notes...
strList - data comes from earlier in the code.
SrchDate.Value exists and has been verified before the below code happens.
sDate1 and sDate2 have been previously defined in the code as Date variables. MAYBE this is the problem? They are dates and not a string?
I'm able to get the IF statement to work. But the ELSE statement is causing me issues.
I THINK I need the following information:
qProducts_MachineCheck.FillWeek Between # sDate1 # And # sDate2 #
However, no matter what I combination of statements I use I end up with errors. I'm so stumped, and would greatly appreciate guidance on this, thank you!
Code Tags Added by UG
Please use Code Tags when posting VBA Code
https://www.access-programmers.co.u...e-use-code-tags-when-posting-vba-code.240420/
Couple of quick notes...
strList - data comes from earlier in the code.
SrchDate.Value exists and has been verified before the below code happens.
sDate1 and sDate2 have been previously defined in the code as Date variables. MAYBE this is the problem? They are dates and not a string?
I'm able to get the IF statement to work. But the ELSE statement is causing me issues.
I THINK I need the following information:
qProducts_MachineCheck.FillWeek Between # sDate1 # And # sDate2 #
However, no matter what I combination of statements I use I end up with errors. I'm so stumped, and would greatly appreciate guidance on this, thank you!
Code Tags Added by UG
Please use Code Tags when posting VBA Code
https://www.access-programmers.co.u...e-use-code-tags-when-posting-vba-code.240420/
Code:
Dim strSQL As String
Dim strSelect As String
Dim strWhere As String
strSelect = "Select * FROM qProducts_Machine "
IF Me.SrchDate.Value = "all" Then
strWhere = "WHERE qProducts_MachineCheck.MachineID IN (" & strList & ");"
ELSE
strWhere = "WHERE qProducts_MachineCheck.MachineID IN (" & strList & ") ????? Between # sDate1 # And # sDate2 # ????? Not sure how to get this here
End If
strSQL = strSelect & strWhere
Last edited by a moderator: