File name as text box name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
Hope someone can assist. I am trying to export a file, have all the code ok
up to a point but am a bit stuck on one point. I want to name the exported
file depending on the value of two text boxes on the form. The first is a
text box and works ok but the second is a date. the code I have is:
Me.txtExportFile = LCase$(Me.txtWBS) + txtDate + ".xls"
With the txtdate being the problem, although i'm not sure how to correct it.
The file name should read textbox29042005.xls with the value of the first
part being textbox and the second part being the date which is in the form
29/04/2005 on the form.... any ideas greatly appreciated.
 
Hi Sam

Use the Format function:

Me.txtExportFile = LCase$(Me.txtWBS) & Format(txtDate, "ddmmyyyy") & ".xls"

Note also that "&" is the preferred operator for joining strings.
 
Me.txtExportFile = LCase$(Me.txtWBS) & Format(txtDate,"ddmmyyyy") & ".xls"

I would also suggest to use a format of yyyymmdd as this would sort
better if you keep a history of files all starting with "textbox".

Regards,
Andreas
 
Back
Top