CreateQueryDef Problems

Gary_Mc_Mahon

Board Regular
Joined
Apr 30, 2003
Messages
87
Hi, Can someone please help me, this is driving me mad. I keep getting run time error with an invalid arguement around the line "set qdf......"

I have the Microsoft DAO 3.6 Object Library selected.

Private Sub Command1_Click()

Dim qdf As DAO.QueryDef
Dim db As DAO.Database
Dim strSQL As String

Set db = CurrentDb

strSQL = "SELECT tbl_RR19_Charge_Bucket_200212.* " & _
"FROM tbl_RR19_Charge_Bucket_200212;"

Set qdf = db.CreateQueryDef("qry_ZZTESTSQL1", strSQL)

DoCmd.OpenQuery "qry_ZZTESTSQL1"


db.QueryDefs.Delete ("qry_ZZTESTSQL1")

Set qdf = Nothing
Set db = Nothing



End Sub

Cheers,
Gary
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I realize this may have been already handled, possibly with your other thread albeit with a different type of question here:
http://www.mrexcel.com/board2/viewtopic.php?t=85962

Your function looks good to me.

If you're still have a problem - what's everything on your references list?
Could there by a fieldname problem/bad SQL?

For some reason, my personal code samples/ones I did years ago with this method, are in the format of:

'DoCmd.OpenQuery "UpdateEquip", , acEdit

It is an update query. Not sure why I kept acEdit.

Mike
 
Upvote 0

Forum statistics

Threads
1,221,683
Messages
6,161,264
Members
451,692
Latest member
jmaskin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top