DoCmd.RunSql syntax problem

BarryMK

4 strings are enough
Local time
Today, 20:56
Joined
Oct 15, 2002
Messages
1,349
Helo folks
I'm just trying to run a make table query from a toggle button on a form (simple enough eh?) and have tried all sorts of syntax from examples in the forum. The Access wizard gives "DoCmd.OpenQuery stDocName, acNormal, acEdit" but this doesn't work, I understand it's because it's an action query.


I've been through many posts on the subject of this command and still can't nail it. This is my best! effort but when I debug I'm getting the message "variable not defined" and tblTrans2 highlighted.

Private Sub tglClear_Click()
On Error GoTo Err_tglClear_Click

DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAppendToTrans2", acNormal, acEdit

DoCmd.RunSQL ("SELECT tblTrans1.* INTO TBL_" & tblTrans2 & " FROM tblTrans1; GROUP BY tblTrans1.*;")

DoCmd.SetWarnings True
Exit_tglClear_Click:
Exit Sub

Err_tglClear_Click:
MsgBox Err.Description
Resume Exit_tglClear_Click

End Sub
 
Last edited:
Code:
DoCmd.OpenQuery "MyQuery"

This works for me.
 
Mile-O-Phile said:
Code:
DoCmd.OpenQuery "MyQuery"

This works for me.

Thanks Mile I'll give it a go. Have a good weekend :)
 
You are implying that tblTrans2 is a variable. Declare your variables and what value is tblTrans2 holding?
 
Thanks for the response sparx but events have overtaken this problem, the users decided there was no advantage in replacing their paper system with a database - after most of the development had taken place. Oh well.:D
 
BarryMK said:
Thanks for the response sparx but events have overtaken this problem, the users decided there was no advantage in replacing their paper system with a database - after most of the development had taken place. Oh well.:D


Luddites! :rolleyes: ;)
 

Users who are viewing this thread

Back
Top Bottom