B
Bakema
Hi there,
My Access database has the possibility to export the
result of a query to Excel. I use a click-event for a
button on a form to make this happen, and the procedure
contains among other things the path for the Excel file
as follows:
strPath = "E:\Database\Excelfiles"
strFileName = "Filename"
strQry = "queryname"
DoCmd.TransferSpreadsheet acExport, 5, strQry, strPath &
strFileName, True, ""
On other computers this path (strPath) may not exist.
This generates error 3044, which then brings up an
InputBox where you can enter an existing path. The entry
in the InputBox then becomes the new strPath and the file
is exported nicely.
Only that in the procedure the old strPath remains as it
is, and next time you run the export facility it will
bring up the same InputBox. Question: how can I use the
response in the InputBox to programmatically replace the
old path with the InputBox response so that error 3044 is
avoided next time you try to export the query.
Question 2 (in case this is quite easy to achieve): if
the response in the InputBox is again not an existing
path, how can I bring up the dialogue box: path does not
exit, do you want to create it now? or something like
that, and then create the path.
Thanks for a reply.
Bakema
My Access database has the possibility to export the
result of a query to Excel. I use a click-event for a
button on a form to make this happen, and the procedure
contains among other things the path for the Excel file
as follows:
strPath = "E:\Database\Excelfiles"
strFileName = "Filename"
strQry = "queryname"
DoCmd.TransferSpreadsheet acExport, 5, strQry, strPath &
strFileName, True, ""
On other computers this path (strPath) may not exist.
This generates error 3044, which then brings up an
InputBox where you can enter an existing path. The entry
in the InputBox then becomes the new strPath and the file
is exported nicely.
Only that in the procedure the old strPath remains as it
is, and next time you run the export facility it will
bring up the same InputBox. Question: how can I use the
response in the InputBox to programmatically replace the
old path with the InputBox response so that error 3044 is
avoided next time you try to export the query.
Question 2 (in case this is quite easy to achieve): if
the response in the InputBox is again not an existing
path, how can I bring up the dialogue box: path does not
exit, do you want to create it now? or something like
that, and then create the path.
Thanks for a reply.
Bakema