run-time variable to supply value to parameter query

WalksFar

New Member
Joined
Sep 7, 2007
Messages
11
OK... newbie here.

I've figured out how to create and use a parameter query. I've seen how the paramaters can be tied to the values on a form, to replace the individual pop-ups with the single form... I'm having a hard time figuring out how to use run-time variable values from a VBA sub instead. Is there a way of supressing the parameter pop-ups from displaying, and to provide the needed values at run-time via VBA?
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

mdmilner

Well-known Member
Joined
Apr 30, 2003
Messages
1,352
Yes, you can embed function calls within SQL statements and have it evaluate to a text result which is then evaluated as a SQL statement.

I'm going to be very lazy and just dump a live example. In this example, DatePuller is a Public Function call that returns a String Value.

Incidentally, the below is a simple reminder query - I have a bunch of tasks (report generation) that are managed from an Access MDB - and the below shows me a list based on predefined schedules of what is left at any given point in time.

Code:
SELECT tblTask.task_name, tblTask.dteStamp, tblTask.ScheduleType, DatePuller([dteStamp],[ScheduleType]) AS Pending
FROM tblTask
WHERE (((DatePuller([dteStamp],[ScheduleType]))>=DateSerial(Year(DatePuller([dteStamp],[ScheduleType])),1,1) And (DatePuller([dteStamp],[ScheduleType]))<=Date()) AND ((IsNull([dteStamp]))=False) AND ((IsNull([ScheduleType]))=False))
GROUP BY tblTask.task_name, tblTask.dteStamp, tblTask.ScheduleType, tblTask.disable
HAVING (((tblTask.ScheduleType)<>'None') AND ((tblTask.disable)=False))
ORDER BY tblTask.ScheduleType, tblTask.task_name, tblTask.dteStamp;
 

Watch MrExcel Video

Forum statistics

Threads
1,123,057
Messages
5,599,545
Members
414,316
Latest member
ExcelLee

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
Top