Unable to call through Command Button

nehachoubey

Board Regular
Joined
Aug 17, 2011
Messages
52
I have written a module ds and called it in command button(Default) like this:
Code:
Sub default_click()
call ds
End Sub
It performs all tasks except for the link with database ie ODBC part. If i run the module it runs perfectly but not throught command click. Plz help!!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
What kind of command button and what module is default_click in?
 
Upvote 0
I'm not sure why, but a couple of things seem odd. When you insert code for an activex button, by default it inserts a private sub like:
Rich (BB code):
Private Sub CommandButton1_Click()
    Stop
    Call ds
End Sub
Also, Call should automatically flip to proper case. How did you insert the procedure?
 
Upvote 0
No its still not working. it works when i am at the same sheet but when i am running the code and i am not at sheet it doesnt work :(
 
Upvote 0
...it works when i am at the same sheet but when i am running the code and i am not at sheet it doesnt work :(

Well, that would be correct. That is why when you created the button, the code is automatically placed in the same sheet's module. The button belongs to the sheet. Place the click event code in the worksheet's module that the button is actually on.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,713
Members
452,939
Latest member
WCrawford

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