Hi there,
I'm new to the forums but I am not new to VBA or SQL.
I'm a pretty advanced in VBA Excel and my SQL skills were honed in SQL Server 2003.
However I'm stuck in a conundrum which I cannot solve.
The problem:
The problem itself is embarrassingly simple. I want to:
My Current code
When I run the code, I simply get an error:
Looking through some posts online I tried restructuring the query a bit:
I was surprised that this even had an effect. This time when running the Macro an input box pops up on the screen:
Now if I type "3441" into this input box Access selects all 2999468 records...
And if I type "0" no records are selected???
Not really sure what's going on... I would be very appreciative if someone could help me out!
Thanks in advance!
~Sancarn
I'm new to the forums but I am not new to VBA or SQL.
I'm a pretty advanced in VBA Excel and my SQL skills were honed in SQL Server 2003.
However I'm stuck in a conundrum which I cannot solve.
The problem:
The problem itself is embarrassingly simple. I want to:
- Use some SQL to select some records from a table.
- Export the produced query as a CSV
My Current code
Code:
Sub test()
DoCmd.RunSQL "SELECT * FROM TippingBucket WHERE StationNum = 3441 INTO Q"
DoCmd.TransferText acExportDelim, "Standard Output", "Q", "C:\Users\jwa\Desktop\TBD\export.csv"
End Sub
When I run the code, I simply get an error:
Code:
Run-time error '3075':
Syntax error (missing operator) in query expression 'StationNum = 3441 INTO Q'.
&Continue
&End
&Debug
&Help
Looking through some posts online I tried restructuring the query a bit:
Code:
Sub test()
DoCmd.RunSQL "SELECT * INTO Q FROM TippingBucket WHERE StationNum = 3441"
DoCmd.TransferText acExportDelim, "Standard Output", "Q", "C:\Users\jwa\Desktop\TBD\export.csv"
End Sub
I was surprised that this even had an effect. This time when running the Macro an input box pops up on the screen:
Code:
Enter Parameter Value
DAL=on
StationNum
OK
Cancel
Now if I type "3441" into this input box Access selects all 2999468 records...

Not really sure what's going on... I would be very appreciative if someone could help me out!
Thanks in advance!

~Sancarn