Full Version: Exporting Query To Excel File
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
pclutts
I have a query (qryConstInsp) that is launched by a command button that has been working well. One of the fields in the query (dateofinsp) has a date prompter in the criteria shown below.

Between [Forms]![frmConstInsp]![txtStartDate] And [Forms]![frmConstInsp]![txtEndDate]

Once the user provides the dates for the prompter and then creates the query datasheet, I would like the system to automatically show a pop up message (form) that asks if the user would like to export the datasheet to an Excel file. The choices on the pop up would be Yes and No. If yes, the data on the query would be exported to an Excel file at a location of the user's choosing. if no, then the pop up message would go away.

Could anyone help me to create this feature? Thanks in advance for your time.
theDBguy
Hi Paul,

We highly recommend not exposing the actual query to the user. In any case, in your command button to open the query, you should be able to add a MsgBox to ask the user if they want to export the query or not.

Just my 2 cents... 2cents.gif
kapeller
Hi Paul

Hope you do not mind me jumping in theDBGuy


Attached is an example with two methods that allows the user to define a date range criteria and as advised by theDBguy keeps the user away from the query.

Excel Example

Hope this helps
pclutts
I just finished looking at your example database. Shouldn't the startdate and enddate be included as part of the query criteria? I tried different dates on the form, and it didn't seem to make a difference in the results. Thanks a bunch for sharing, because I can use the code.
kapeller
Hi Paul

Take a look at this

Link
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.