Dreaded 3067 No Query error.

Bremen217

Registered User.
Local time
Today, 00:06
Joined
Nov 24, 2010
Messages
19
Ok so I've strained my eyes and looked elsewhere before bothering people on the forums but I cant get this to work in Access 07 VB:

Private Sub Command3_Click()
If [Forms]![NORAM Subform]![previousDate] = "" Then
MsgBox "No previous date entered.", vbExclamation
Exit Sub
Else
Dim newDate As String
newDate = [Forms]![NORAM Subform]![previousDate]
Dim strSQL As String
strSQL = " SELECT * INTO " & newDate & " FROM [Global Data] "
DoCmd.RunSQL strSQL

strSQL = "DELETE * FROM [Global Data]"
DoCmd.RunSQL strSQL

End If
End Sub

I get the 3067 error on the red runSQL shown above.


Any suggestions would be much appreciated.
Thanks!
 
Last edited:
newDate = "[Forms]![NORAM Subform]![previousDate]"
 
newDate = "[Forms]![NORAM Subform]![previousDate]"
Sorry, but that would just put that literal string into the newDate variable instead of putting a date in.


I do see an extra space at the beginning of the strSQL assignment and I think it doesn't like having a space at the beginning like that.
 
Sorry I was only half paying attention while on the phone helping a guy with problems on our website.

Did I say half? More like five percent with a stupid suggestion like that.:o

Set a break point and see what the SQL variable shows.
 
Okay, I just tested and found the problem. It is the date format that is causing the problem (the / )

So, change this code:
Code:
Dim newDate As String
newDate = [Forms]![NORAM Subform]![previousDate]

To this
Code:
Dim newDate As String
newDate = [COLOR=red][B]Format([/B][/COLOR][Forms]![NORAM Subform]![previousDate][B][COLOR=red], "mmddyyyy")[/COLOR][/B]

And it should get rid of the 3067 error.
 
Mr Larson you are in fact my hero of the day! Thank you so much! Happy Thanksgiving everyone!
 

Users who are viewing this thread

Back
Top Bottom