Output file to location specified in a textbox

DKM

Registered User.
Local time
Today, 11:07
Joined
Feb 24, 2007
Messages
24
Hi

Tried searching but couldnt see anything on the same lines. Pretty much as the title. I am currently trying to set up a couple of autoexports (have the actual export code sorted, will export in format and to a location hard coded into vb). What i want to do though is to get the code to take the file path from a textbox on a seperate table so that it can be updated relativly easily if required in future

Cheers
 
Change your path in your code to

If the form is open:
Dim strPath As String
strPath = Forms!YourFormName.YourTextboxName

and then use strPath in place of the hard coded value.

If the form is not open and you want to look it up in a table, you could assign it similarly by using DLookup.
 
Many thanks for that. Worked wonderfully with the Dlookup way.

Code used in the end.

Private Sub ButtonName_Click()
Dim varX As Variant
varX = DLookup("[Fieldname]", "Tablename")
DoCmd.OutputTo acOutputQuery, "Nameofitemtoexport", acFormatXLS, varX, True
End Sub
 

Users who are viewing this thread

Back
Top Bottom