Rename Image File - Skip

  • Thread starter Thread starter j.t.w
  • Start date Start date
J

j.t.w

Access 2000.
Windows 2000 Pro and Windows XP Pro Desktops.

I have a subform (on a form) that displays a tif image. As I rename
the image, the image is renamed and moved to another file location and
the next image is displayed for me to rename. So far this works
correctly. The problem that I am having is that sometimes I come
across an image that I do not want to rename (and move). How do I move
to the next image? It seems as though the order the images are being
selected are by the date it was created.

Basically, I would like to "skip" (or disregard) the current image and
move to the next.

Could someone please let me know if this is even possible and how I
should go about solving this problem?

Here is a short version of what I have...

Private Sub cmdRenameFile_Click()
Dim strSourcePath As String
Dim strDestinationPath As String
Dim strExt As String
Dim strDir As String

strSourcePath = "\\ServerName\Images\"
strDestinationPath = "\\ServerName\Images\Renamed\"
strExt = ".tif"

strOldName = strSourcePath & txtCurrentName
strNewName = strDestinationPath & cboNewName & strExt

‘Rename the file.
Name strOldName As strNewName

‘Get the next file.
strDir = Dir(strSourcePath & "*.tif")

Forms!Rename_Files_frm!Rename_Files_subfrm.Form.imgDocument.Picture =
strSourcePath & strDir
txtCurrentName = strDir
cboNewName = ""
End Sub

Thank you in advance for any and all help.
j.t.w
 
'Rename the file.
Name strOldName As strNewName

See if this will help:

'Rename the file.
If Nz(cboNewName, "") <> "" Then
Name strOldName As strNewName
End If

If desired, you could add an Else statement to the If to pop-up a message
box verifying that cboNewName wasn't left blank by accident and retry if it
was.
 
Wayne,

Thanks for your response.

I understand that the "If" statement will skip the renaming of the
file, but what I would like to do next is move to the next tif file in
the directory without having to do anything with the current tif file.

Example of contents in the directory (in this order):

SCN_11111111111.tif
SCN_22222222222.tif
SCN_33333333333.tif
SCN_44444444444.tif
etc.

Currently, when I rename and move the files as they are being
displayed, the next image gets displayed where I can then rename that
one. How would I go about looping through the directory and skipping
the "SCN_33333333333.tif" image and then move on to the
"SCN_44444444444.tif"? Note: Prior to the file being displayed, I
wouldn't neccessarily look at or know what image I would like to skip
until that time.

Anyway, hopefully I explained this well enough. Please let me know if
you need more information.

Thanks.
j.t.w
 
On subsequent calls of Dir, if you use no arguments, you'll get the next
file in line. So, you need to know if you've been through once already. In
your case, you could probably use the fact the txtCurrentName has a file
name in it instead of the "flag" variable that I've used. I assume
txtCurrentName would be blank until you get the first file.

Example:
Private Sub Command3_Click()
Static bolBeenHere As Boolean
If bolBeenHere Then
Me.Text4 = Dir
Else
Me.Text4 = Dir("c:\windows\*.*")
End If
bolBeenHere = True
End Sub
 
Thanks Wayne,

I'll give that a try.

j.t.w




Wayne Morgan said:
On subsequent calls of Dir, if you use no arguments, you'll get the next
file in line. So, you need to know if you've been through once already. In
your case, you could probably use the fact the txtCurrentName has a file
name in it instead of the "flag" variable that I've used. I assume
txtCurrentName would be blank until you get the first file.

Example:
Private Sub Command3_Click()
Static bolBeenHere As Boolean
If bolBeenHere Then
Me.Text4 = Dir
Else
Me.Text4 = Dir("c:\windows\*.*")
End If
bolBeenHere = True
End Sub
 

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

Back
Top