mmitchmcp
Jul 8 2009, 06:57 AM
I had an application that I created in Access 2003 with many command buttons that opened queries.
Recently Access 2003 was updated to Access 2007 and now none of my queries work.
Code:
Private Sub Command300_Click()
On Error GoTo Err_Command300_Click
SELECT hf_base_onesec_0040.*
FROM hf_base_onesec_0040;
Exit_Command300_Click:
Exit Sub
Err_Command300_Click:
MsgBox Err.Description
Resume Exit_Command300_Click
End Sub
Could someone please tell me the problem?
Thanks
MMITCHMCP
Scott McDaniel
Jul 8 2009, 07:27 AM
The code you supplied is incomplete; simply writing a SELECT statement in the Click event of query does nothing, and should throw an error when you click on Command300. Is this a direct copy/paste from your application?
Also, be aware that you must either (a) enable Macros in your database or (b) make sure the database is located in a Trusted Location. You can add a Trusted Location in Access 2007 (or any of the Office products):
http://office.microsoft.com/en-us/help/HA100319991033.aspx
Paul_Churchill
Jul 8 2009, 07:36 AM
I would expect to see something like:-
Private Sub Command300_Click()
On Error GoTo Err_Command300_Click
dim strSql as string
strSql = "SELECT hf_base_onesec_0040.* FROM hf_base_onesec_0040;"
docmd.runSQL strsql
Exit_Command300_Click:
Exit Sub
Edited by: Paul_Churchill on Wed Jul 8 8:44:03 EDT 2009.
mmitchmcp
Jul 8 2009, 07:49 AM
Thanks----
Yea the syntax I see now is wrong in that statement. I added the folder containing the databases
to the trusted location as you suggested and all is working fine now.
Thank You Scott.
Paul--Would the strSQL command be more for web access via a script language
or would this also work for VBA too?
Mark
Paul_Churchill
Jul 8 2009, 07:53 AM
Its for vba
and the SQL statement must be expressed as as string - the one in your example is short and simple but they can get quite lcomplicated
as to web access, I cannot comment as I have not done any -yet!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.