File name from Text box

pinkis4girls

New member
Local time
Today, 00:04
Joined
Mar 24, 2007
Messages
9
I have double posted this under forms and reports, as I'm not sure which place it is best suited.

Hi,

I'm sure I'm not the first and won’t be the last to ask this. I'm trying to create my report with a dynamic file name from one of the text boxes [Tender Name] in my form/report.

Currently I have;

Private Sub Quoterequest_Click()
Dim stDocName As String

[Contract Reason].Value = "Normal" Then

stDocName = "Quote Request wip"
DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenReport stDocName, acPreview, , "[Ref]= forms!Tenderdata![Ref]"
DoCmd.OutputTo acReport, stDocName, acFormatRTF, "C:\TEMP\quotation.doc", True
DoCmd.Close acReport, "Quote Request wip"

End Sub

I'm assuming this is a simple change required to;

DoCmd.OpenReport stDocName, acPreview, , "[Ref]= forms!Tenderdata![Ref]"
DoCmd.OutputTo acReport, stDocName, acFormatRTF, "C:\TEMP\quotation.doc", True


But I've tried a few things and it's not changing the saved filed name.

Any help will be much appreciated, just a nudge in the right direction; I have tried searching for an answer already posted but can’t kind find a simple solution. I’m sure I have done this before but can’t remember how (all my notes were deleted in a rather upsetting USB stick incident a couple of months ago).
 
I'm trying to create my report with a dynamic file name from one of the text boxes [Tender Name] in my form/report. [/FONT][/COLOR]
you want to save the report in a folder on your local machine with the name from the form's textbox? Is THAT right?
DoCmd.OpenReport stDocName, acPreview, , "[Ref]= forms!Tenderdata![Ref]" <--- this filters the report. Is that what you want?
DoCmd.OutputTo acReport, stDocName, acFormatRTF, "C:\TEMP\quotation.doc", True <--- If you're referring to the problem of the textbox file name here with this line of code, I don't get the connection...
 
No double posting

I have double posted this under forms and reports, as I'm not sure which place it is best suited.
Don't double post. Post it in the place you think is best and if you wind up deciding otherwise use the "Report Post" link (Exclamation mark in red triangle) and a moderator can move it to a different location.
 
Hi Adam -

Yes that is right. My terminology is a bit dodgy. I'm still learning.

Yes I want to filter the report; I'm just trying to export one record to Word and save it under the textbox file name.

Currently it exports and calls the file "quotation.doc" (As per my code location). I thought it would be simple addition to change this name to [tender name].

I understand that there are probably far more eloquent ways of achieving this, I'm still not really sure what I'm doing - I just know what I have so far is fit for purpose, although it would be nice if the file saved it's self. Currently the user has to "save as"

Bob - Sorry about the double post. Consider wrist slapped.
 
I'm just trying to export one record to Word and save it under the textbox file name.
this is the way you reference a textbox if you want that value as the file name:
Code:
DoCmd.OutputTo acReport, stDocName, _
   acFormatRTF, "C:\TEMP\" & me.TextBoxName & ".doc", True
 
I was missing the & when I tried - thank you so much. It worked perfectly, as you know it would. :)

Sorry it wasn't a very challanging question but thank you for taking the time to answer it.
 
it's more challenging than you think sometimes. Good luck. :)
 

Users who are viewing this thread

Back
Top Bottom