File Rename using Common Dialog Box in Access

G

Guest

In an application I am writing, I would need to:
1) open a common dialog box to look at files
2) select one file
3) Change the name of the file to be the same as one of the field values in
the form
4) Click Save and have the system actually rename the file.

I can do 1, 2 , 3 but when I click Save or Open on the Common Dialog Box,
nothing actually happens and the original file name does not change.
(The few lines of code are further below)
Can anybody in this esteemed community of experienced people tell me what I
am doing wrong and / or suggest a work around? Thank you very much

____Code:_____________________________________

Me.CDialog1.ShowSave (CDialog1 is the name of the CommonDialogBox)

With Me.CDialog1
Me.CDialog1.FileName = Me.Address (Me.Address contains the new name
for the file I want to rename)
Me.CDialog1.DefaultExt = ".jpg"
End With
Me.CDialog1.FileName = Me.Address & ".jpg"
___________________________________________

I also tried to put the last line within before the "End With" but nothing
happens.
 
D

Douglas J. Steele

AFAIK, you can't use the dialog for that purpose. However, once you know the
full path of the file that you want changed, and you know what you want to
change its name to, you can use the VBA Name statement:

Name oldpathname As newpathname
 
G

Guest

Your suggestion was great, simple, elegant and effective. Thank you very much
Douglas.
I had to do some additional coding to work around the chance of trying to
rename a file the same as an existing file, but everything works great now.
Thank you again
Gino (qosmik)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top