Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programming Custom or Existing Toolbar Buttons 1

Status
Not open for further replies.

mdaniele

Technical User
Joined
Sep 18, 2003
Messages
20
Location
US
The query is simple, a criteria search that filters all the records in my table based on the [Description] field.
I have a query that I've attached to a button on my toolbar which allows me to; while I'm looking at my table, hit the button, the parameter request dialog appears, I type in my string, and the query table appears with all the records filtered down, I make my edits and shut down the query.

Instead of a parameter type query dialog, I want to have a toolbar button similar in style to the MS GoToField toolbar button, that will allow me to just type in the string and on enter, run the query without the parameter dialog. (Also wished it could filter the current table rather than bring up another set of records but - no biggie) Anyone know have any knowhow on creating/programming or modifying an existing toolbar button?

...and when Satan lividly demanded to know why the old man did not exhibit any fear whatsoever of him, the 82 year old man calmly replied "why hell, you ain't so bad, I've been married to your sister for over 50 years"
 
Hi,

A toolbar button can do one of three things:
* Run a macro
* Run a VBA function (it cannot run a Sub)
* Run any item which has a RunCommand constant (these are the standard items on the file, edit, records, window and help menus etc).

Therefore, if you create a form to do your searching, and a VBA function that opens it, you can add a button to your custom toolbar that runs this function - which will run your form from which you can carry out your search.

John
 
As this is true for the custom toolbar buttons that can be created from the customize menu, I'm really seeking info on creating custom conmand buttons similar to the "stock" buttons like GoTOField or FontSize, i.e. buttons where the user inputs a value and the program responds to the input value. In this case, instead of changing the fontsize I want the input to be the search string used for a query's criteria. I think it's possible with VB (which I dabble with) or C+ (which is what I recall reading was used for most of the "stock" buttons, and which I don't dabble with).
It's not really that complicated when you really think about it, just another button that allows input, then filters and retrieves all records that have any part of the input string contain that input.
Currently I do it with a query button, and then get a parameter request dialog box. Bascially, I just want to shortcut right to the dialog input.

...and when Satan lividly demanded to know why the old man did not exhibit any fear whatsoever of him, the 82 year old man calmly replied "why hell, you ain't so bad, I've been married to your sister for over 50 years"
 
Function fFilter()
Dim strfltr As String
strfltr = Screen.ActiveControl.Name & "='" & InputBox("what?") & "'"
Screen.ActiveDatasheet.Filter = strfltr
Screen.ActiveDatasheet.FilterOn = True
End Function

It may need some refining...

HTH


[pipe]
Daniel Vlas
Systems Consultant

 
Hi
how to enable or Disable a button on a tool bar?
Code:
CommandBars("NetsWord").Controls("EsscrowDoc").Enabled = False
But VB give an error message that invalid call.
What to do and how to do?
 
MrCodePK

This is a new problem, please start a new thread for it.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top