UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Command Button in Access 2007    
 
   
mmitchmcp
post Jul 8 2009, 06:57 AM
Post #1

UtterAccess Member
Posts: 24



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
Go to the top of the page
 
+
Scott McDaniel
post Jul 8 2009, 07:27 AM
Post #2

UtterAccess VIP
Posts: 569
From: North Augusta, SC



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
Go to the top of the page
 
+
Paul_Churchill
post Jul 8 2009, 07:36 AM
Post #3

UtterAccess VIP
Posts: 1,342
From: Barton-under-Needwood, Staffordshire, England



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.
Go to the top of the page
 
+
mmitchmcp
post Jul 8 2009, 07:49 AM
Post #4

UtterAccess Member
Posts: 24



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
Go to the top of the page
 
+
Paul_Churchill
post Jul 8 2009, 07:53 AM
Post #5

UtterAccess VIP
Posts: 1,342
From: Barton-under-Needwood, Staffordshire, England



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!
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th June 2013 - 03:26 AM