How to: OnClose run Make Table Query

E

Ember

I have a form "Close" control. I have a Make Table Query that I would like
to be run when the close control is clicked. I keep getting an error that
and expected statment is missing, here is my code:

Private Sub cmdCloseFile_Click()
On Error GoTo Err_cmdCloseFile_Click

DoCmd.SetWarnings (WarningsOn)

Dim strSQL
strSQL = "SELECT (tblFiles.[Project Name], tblFiles.[Project Number],
tblFiles.[Project Manager]), INTO tblProjects FROM tblFiles GROUP BY GROUP BY
tblFiles.[Project Name], tblFiles.[Project Number], tblFiles.[Project
Manager]"
DoCmd.RunSQL SQL

DoCmd.Close

Exit_cmdCloseFile_Click:
Exit Sub

Err_cmdCloseFile_Click:
MsgBox Err.Description
Resume Exit_cmdCloseFile_Click

End Sub

Thanks for any help!
Ember
 
J

J. Goddard

First, there should be no brackets around the field list following SELECT
Second - you have an extra comma before INTO
Third - you have GROUP BY twice

strSQL = "SELECT tblFiles.[Project Name], tblFiles.[Project Number],
tblFiles.[Project Manager] INTO tblProjects FROM tblFiles GROUP BY
tblFiles.[Project Name], tblFiles.[Project Number], tblFiles.[Project
Manager]"

John
 
E

Ember

Thanks I will try it. I thought I was close...grammar was always my problem
in English class guess it still is. :)

Ember

J. Goddard said:
First, there should be no brackets around the field list following SELECT
Second - you have an extra comma before INTO
Third - you have GROUP BY twice

strSQL = "SELECT tblFiles.[Project Name], tblFiles.[Project Number],
tblFiles.[Project Manager] INTO tblProjects FROM tblFiles GROUP BY
tblFiles.[Project Name], tblFiles.[Project Number], tblFiles.[Project
Manager]"

John

I have a form "Close" control. I have a Make Table Query that I would like
to be run when the close control is clicked. I keep getting an error that
and expected statment is missing, here is my code:

Private Sub cmdCloseFile_Click()
On Error GoTo Err_cmdCloseFile_Click

DoCmd.SetWarnings (WarningsOn)

Dim strSQL
strSQL = "SELECT (tblFiles.[Project Name], tblFiles.[Project Number],
tblFiles.[Project Manager]), INTO tblProjects FROM tblFiles GROUP BY GROUP BY
tblFiles.[Project Name], tblFiles.[Project Number], tblFiles.[Project
Manager]"
DoCmd.RunSQL SQL

DoCmd.Close

Exit_cmdCloseFile_Click:
Exit Sub

Err_cmdCloseFile_Click:
MsgBox Err.Description
Resume Exit_cmdCloseFile_Click

End Sub

Thanks for any help!
Ember
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top