PC Review


Reply
Thread Tools Rate Thread

Command button to run macro in a module

 
 
DG
Guest
Posts: n/a
 
      21st Mar 2007
My spreadsheet has an ODBC query in it that pulls data from an SQL database.
This has been placed in a macro named Refresh_Query() in Module1.

I put a command button from the Control Toolbox and named it RefreshButton.
Then double clicked the button to go into VB editor and in Shee1(Sheet1) it
has a Private Sub RefreshButton_Click(). I put Refresh_Query() in here:

Private Sub RefreshButton_Click()
Refresh_Query()
End Sub

When I hit enter after typing Refresh_Query() I get an error: "Compile
error: Expected: =".

What does this mean? I know I've done this before. Do I need to declare
something as global?

Dan


 
Reply With Quote
 
 
 
 
DG
Guest
Posts: n/a
 
      21st Mar 2007
Never mind, I found it.

Did not need the ().


"DG" <(E-Mail Removed)> wrote in message
news:%23acj5d$(E-Mail Removed)...
> My spreadsheet has an ODBC query in it that pulls data from an SQL
> database. This has been placed in a macro named Refresh_Query() in
> Module1.
>
> I put a command button from the Control Toolbox and named it
> RefreshButton. Then double clicked the button to go into VB editor and in
> Shee1(Sheet1) it has a Private Sub RefreshButton_Click(). I put
> Refresh_Query() in here:
>
> Private Sub RefreshButton_Click()
> Refresh_Query()
> End Sub
>
> When I hit enter after typing Refresh_Query() I get an error: "Compile
> error: Expected: =".
>
> What does this mean? I know I've done this before. Do I need to declare
> something as global?
>
> Dan
>



 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      21st Mar 2007
DG

Remove the () after Refresh_Query


Gord Dibben MS Excel MVP

On Wed, 21 Mar 2007 16:28:22 -0400, "DG" <(E-Mail Removed)> wrote:

>My spreadsheet has an ODBC query in it that pulls data from an SQL database.
>This has been placed in a macro named Refresh_Query() in Module1.
>
> I put a command button from the Control Toolbox and named it RefreshButton.
>Then double clicked the button to go into VB editor and in Shee1(Sheet1) it
>has a Private Sub RefreshButton_Click(). I put Refresh_Query() in here:
>
>Private Sub RefreshButton_Click()
> Refresh_Query()
>End Sub
>
>When I hit enter after typing Refresh_Query() I get an error: "Compile
>error: Expected: =".
>
>What does this mean? I know I've done this before. Do I need to declare
>something as global?
>
>Dan
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assign Module to Command Button Andibevan Microsoft Access 4 9th Nov 2005 02:39 PM
command button for vba module =?Utf-8?B?ZGVsbWFj?= Microsoft Excel Programming 1 23rd Jun 2005 06:04 PM
Executive a Module with a Command Button Larry Microsoft Access VBA Modules 1 9th Sep 2004 04:30 PM
Running a module from a command button Luther Microsoft Access Form Coding 1 11th May 2004 03:28 PM
Run a module from command button or macro Daivd Microsoft Access VBA Modules 2 4th Dec 2003 11:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:48 PM.