Form Command to refresh Query

TDC21

Board Regular
Joined
Mar 31, 2017
Messages
97
I have a query that is referencing the entries made in a Form. On the Form I have a command button that will open the query. The query is referencing form entries and filtering as expected now but the query has to be either closed or refreshed each time new data is entered onto the form. Could the Run query command be altered to Run query or if Query is open, then refresh query? If not is there a Command that I could add to the form to refresh the query?

I have looked online and all I found was a reference from 2007 saying that Access dose not contain any refresh commands, is that still the case or is there anything I can do to simplify this operation?

Thanks again everyone
 
In general terms, it sounds like I would have a main form with all of the controls you'd want to search by, arranging them from left to right starting with the major criteria (main parent) if there is such a relationship. On this form, a subform datasheet or continuous form (cf) based on a query that returns records according to the criteria provided by the main form. One advantage to the cf is that you can easily reference a particular row, so if you put a command button in the detail section (as part of the record) clicking it can reference the row it's on. Useful if you'd want to open a report based on one particular row as long as you don't mind a repeat of the button on every row. Possible to do this with one button in the cf header or footer as well, but sometimes it's far above or below the desired record and may not be as intuitive.

The most difficult part of the approach is having to deal with controls that only contain values for the query part of the time. If Null, they usually have to be ignored to produce the desired records. Using vba, the main part of a sql statement is written and depending on which of the controls contain data, the WHERE part is appended to concatenate the remainder. Then the query is opened/executed or the report/form is opened. There are lot's of examples on how to create such a search form.

While I did work in a steel mill, my background was maintenance, so I'm guessing that HEAT is a parent value from which many slabs might be produced whether or not it is continuous casting or ingots. So SLAB is a child of HEAT; MTR is material test report and is specific to a particular slab; THICK is a characteristic of a particular slab. Thus I might arrange combos, left to right, as HEAT, SLAB, THICK and MTR. These controls would have row sources but not control sources. As mentioned, check out search forms.
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,221,672
Messages
6,161,199
Members
451,688
Latest member
Gregs44132

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