SQL formatting

Missing Option Explicit?

Code:
strTWhere = ("[SOP Nu ....
...
If DCount("*", "[Main TBL]", strWhere) > 0 Then
...
strTWhere vs. strWhere
 
That's the problem - the debug/print is blank
You need
Code:
Debug.Print strTWhere

Use use Debug.Print <YourVariable> AFTER you set anything, not before.

You have set strTWhere to some text so it cannot possibly be blank?
 
I am back to my original issues of data mismatch and I know it is because I have the strWhere statement incorrect but I don't know how to correct it. I am away until Monday and will be back at this again then. Have a great weekend everyone
 
I am back to my original issues of data mismatch and I know it is because I have the strWhere statement incorrect but I don't know how to correct it. I am away until Monday and will be back at this again then. Have a great weekend everyone
You have been shown an easier method, where type mismatch is hard to accomplish?
@MajP has a function to build the SQL correctly.

If you still insist on trying to build it yourself?

Strings need to be surrounded by single quotes ' unless it contains a single quote, then triple double quotes works, I think?
Date literals with # and in mm/dd/yyyy or yyyy-mm-dd format
Numbers do not need anything

Also for anything other than one item of criteria, I tend to put the the criteria into a string variable and then debug.print it, until correct then also use that in the code.

Added benefit is, if you still cannot see the error, you can copy and paste back here the output from the debug.print for someone else to spot it. :)
 
Super big thanks to everyone Especially gasman for the explanation of how to set up strings with the correct notation (not sure of the correct wording) After what I call "poking it with a stick" I was able to find the correct sql stateiment. And also to theDBguy for our email exchanges willingness to connect via the web. So happy I can continue the fight!
 
Super big thanks to everyone Especially gasman for the explanation of how to set up strings with the correct notation (not sure of the correct wording) After what I call "poking it with a stick" I was able to find the correct sql stateiment. And also to theDBguy for our email exchanges willingness to connect via the web. So happy I can continue the fight!
Glad to hear you got it sorted out. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom