Select Into Value From a form

tlolas

New member
Local time
Today, 03:51
Joined
Mar 12, 2009
Messages
1
I have a user that needs to be able to input the name of the table that is to be created on a form and hit the button. Then change the value on the form and replicate process with a new table name. Is this possible?

This was my stab at it but not working.

SELECT UCase(ListsToSend.FNAME) AS FNAME
INTO [Forms]![f_DMMProcessing]![Text8] IN 'S:\Target.mdb'
FROM ListsToSend
WHERE (((ListsToSend.TOURCODE)=[Forms]![f_DMMProcessing]![Text8]));


Another Option Might be if anyone could tell me if I can export a .csv of the query with the file name from the form field as in
S:\[Forms]![f_DMMProcessing]![Text8].csv
 
Last edited:
Hi

I think you best bet would be to create the table in the current DB and then export it to the target DB

Insert someyhing like this your button click event:

strQuery = "SELECT ... INTO [" & table_name_textbox & "] FROM ... WHERE ... = '" & table_name_textbox & "'"

DoCmd.RunSql(strQuery)
DoCmd.TransferDatabase (check the correct syntax for this)
DoCmd.DeleteObject acTable, your_table_name (if you don't need it anymore in the current DB)

Hope that helps,

Simon B.
 
you could enter the file name into a text box on the form

or even a folder name, and a file name

--------
but most developers would use a fileopensavedialog, and enter the file name they want that way. by navigating to it - lots of examples to be had - i think later versions of access include one anyway. i suppose everyone fins one they like and sticks with it, even when access build these things in

--------
also

you can export a csv (or import for that matter)
or a spreadsheet directly (import/export)
or an email directly
or an email less directly (preview a report, then select file/send to)

look at

docmd.transfertext etc
docmd.transferspreadsheet etc
docmd.outputto etc

all these have appropriate parameters for filein/fileout tablein/tableout/ hasheaders etc etc - access automation/integration is really powerful
 

Users who are viewing this thread

Back
Top Bottom