unusual export to excel (1 Viewer)

PhilipEwen

Registered User.
Local time
Today, 17:07
Joined
Jun 11, 2001
Messages
81
Hi,
I am currently generating a dynamic query based on form selections. The query then opens a form showing results. The user then gets the choice to export to Excel ( using macro ). A dynamic query is generated "dynam_qry" and used to show results and later export to excel.

The problem is that now we need to have multiple users. I am afraid that a dynamic query would be created, and before the person hits 'export to excel', another user has generated a query overwriting the old query ( same name ). Therfore if user 1 then hits 'export' the new query will have oversaved the previous one and they will export the wrong data.

One way i have thought ( probably wrong ! ) is to generate a random number to append to name of query, thus generating 'random' query. Call the dynamic query "query_23732489238" for example. Then delete the query upon export.

Don't know if this is the best way though - advice appreciated !

Perhaps a better way would be to use VBA to query by the same variable, store the variable and if export was chosen then use the variable again - as against creating query, storing query as a variable in memory until export is chosen, then using variable to query and then export.

Is this possible or a good way of doing it ?
If so - any ideas of how to do it would be great.
I am quite a newbie to VBA so links / guidance would be greatly appreciated.

Many thanks in advance

Phil.
 
Last edited:

crosmill

Registered User.
Local time
Today, 17:07
Joined
Sep 20, 2001
Messages
285
In my opinion your going about the right way, just stick a unique identifier to the end of the name.

what I would do though is to use a date/timestamp instead of a compleatly random number, no real reason for this other than it makes the name a bit more relevant.

it should be a pretty easy thing to do, but post back if you get stuck.

hth
 

PhilipEwen

Registered User.
Local time
Today, 17:07
Joined
Jun 11, 2001
Messages
81
Thanks very much for your reply / advice.
The date time stamp is a great idea - i'm gonna do a bit of searching around now for advice.

Out of interest, seeing as I will have to store the query name as a variable anyway ( so i can go back and delete it after ) - would it not make sense to just store the entire query as a variable and execute this within VBA code ?
Not sure if that has any inpact preformance issues or pros / cons.
( don't even know how to do it a present anyway, just thought it may be possible )

Thanks again for your help - any more advice from anyone would be appreciated.
 

crosmill

Registered User.
Local time
Today, 17:07
Joined
Sep 20, 2001
Messages
285
Can you explain a bit more about the setup.

the impression I get at the moment is that the user selects options which then builds a query 'on the fly' and exports it to an excel file.

how are you building the query, are you using creating SQL code behind forms, or in VBA, or passing parameters to a query?
 

Users who are viewing this thread

Top Bottom