PC Review


Reply
Thread Tools Rate Thread

ahtCommonFileOpenSave

 
 
RJF
Guest
Posts: n/a
 
      8th Aug 2008
I have been using the code below to export a query to a .txt file, letting
the user select the path and type in the file name. It works great.

However, the users now want to still select the path, but instead of typing
in the file name, they want me to create a variable that will automatically
name the file. I created the variable YYMM_01 that contains the file name.

Can someone help me change this so that the user does not need to type in a
file name, but it automatically grabs the variable?

Thank you in advance for any help you can give me.

strfilter = ahtAddFilterItem(mystrFilter, "Text Files (*.txt)", "*.txt")
strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strfilter, _
Flags:=ahtOFN_OVERWRITEPROMPT Or
ahtOFN_READONLY)

DoCmd.TransferText acExportFixed, "ERSCUST_Laser_Export_Spec", "qry_Laser",
strSaveFileName

--
RJF
 
Reply With Quote
 
 
 
 
Chris O''''Neill
Guest
Posts: n/a
 
      10th Aug 2008
If this is the function you're using:

http://www.mvps.org/access/api/api0001.htm

Then the 6th argument you can pass to it is a default filename for the
filename text box. Pass your variable YYMM_01 there and see what happens.
If that's the only variable you want to pass, your code will look like this:

ahtCommonFileOpenSave( , , , , , YYMM_01)

Hope that helps...

Regards, Chris

P.S. I hope you're somehow making sure the value of YYMM_01 is different
each time it's used. Otherwise, there's a good possiblity of one user
overwriting what was saved by another user.

"RJF" wrote:

> I have been using the code below to export a query to a .txt file, letting
> the user select the path and type in the file name. It works great.
>
> However, the users now want to still select the path, but instead of typing
> in the file name, they want me to create a variable that will automatically
> name the file. I created the variable YYMM_01 that contains the file name.
>
> Can someone help me change this so that the user does not need to type in a
> file name, but it automatically grabs the variable?
>
> Thank you in advance for any help you can give me.
>
> strfilter = ahtAddFilterItem(mystrFilter, "Text Files (*.txt)", "*.txt")
> strSaveFileName = ahtCommonFileOpenSave( _
> OpenFile:=False, _
> Filter:=strfilter, _
> Flags:=ahtOFN_OVERWRITEPROMPT Or
> ahtOFN_READONLY)
>
> DoCmd.TransferText acExportFixed, "ERSCUST_Laser_Export_Spec", "qry_Laser",
> strSaveFileName
>
> --
> RJF

 
Reply With Quote
 
Chris O''''Neill
Guest
Posts: n/a
 
      10th Aug 2008
Opps! I didn't notice that you're using named variables. In that case, your
code should look like this:

strSaveFileName = ahtCommonFileOpenSave( _
OpenFile:=False, _
Filter:=strfilter, _
Flags:=ahtOFN_OVERWRITEPROMPT Or
ahtOFN_READONLY, _
FileName:=YYMM_01)

 
Reply With Quote
 
RJF
Guest
Posts: n/a
 
      11th Aug 2008
It works perfectly!

Thank you so much, Chris. I really appreciate the help and the quick
response.

-Rachel

--
RJF


"Chris O''''Neill" wrote:

> Opps! I didn't notice that you're using named variables. In that case, your
> code should look like this:
>
> strSaveFileName = ahtCommonFileOpenSave( _
> OpenFile:=False, _
> Filter:=strfilter, _
> Flags:=ahtOFN_OVERWRITEPROMPT Or
> ahtOFN_READONLY, _
> FileName:=YYMM_01)
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: ahtCommonFileOpenSave Jeanette Cunningham Microsoft Access 1 25th May 2008 12:29 PM
ahtCommonFileOpenSave SF Microsoft Access 3 25th May 2008 08:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:29 AM.