Hook Query to button on forum

amerifax

Registered User.
Local time
Today, 17:16
Joined
Apr 9, 2007
Messages
304
I am trying to connect the following code within a button on a form:

SELECT [MST-SC-Muni].[Municipality], [MST-SC-Muni].SC, [MST-SC-Muni].TypeCity, [MST-SC-Muni].County, [MST-SC-Muni].WRK
FROM [MST-SC-Muni]
ORDER BY [MST-SC-Muni].[Municipality];

The button should run this code and then open a fine replace.

I don't have a clue on how to connect this to a button that is on a form. I sure could use help. My experience with Access 2013 is less than limited.
Bob
 
If you are doing a Find and replace, have you considered a lookup table? I'm not sure of your context, and maybe my idea doesn't apply. I have no experience with 2013.
 
The button should run this code and then open a fine replace.
That SQL code is just a Select Query and it's not going to do anything other than return records in a query. It's also not a piece of code that you can run.

I suspect what you may be looking for is an Update Query, where criteria and changes are specified. For example:

Code:
UPDATE tblCities SET CityDescription = "Metropolis" WHERE Population > 10000000;

Then, on a button click, a bit of code could 'run' it.

Code:
With DoCmd
    .SetWarnings False
    .OpenQuery "QueryNameHere"
    .SetWarnings True
End With
 
My Button has to give me a sort "SQL" and continue on to open a Find Replace command. I'm using a split window. It would be the same as selecting the top of the lower, bottom of split window, and selecting the sort order. Than going to the Find Replace icon and searching. The button would be easier to do both.

My records are only ro search. They never get another record added. At times I do Edit a record but never add additional records.

Bob

Mile-O (Where would I add the code to.)
Bob
 
Last edited:

Users who are viewing this thread

Back
Top Bottom