When you click Ok on the msgbox i what it to repeat the process that it has just done.
Private Sub Form_Current()
Dim WholeSpec As String
Dim Filefolder As String
Dim Filename As String
Dim s As String
Dim i As Integer
If IsNull(Me.txtname) Then
Me.Image.Picture = "" 'No image
Else:
WholeSpec = Me.txtname
Filefolder = Mid(WholeSpec, 1, InStrRev(WholeSpec, "\") - 1)
Filename = Mid(WholeSpec, InStrRev(WholeSpec, "\") + 1)
If (Left(Me.txtname, 1) = "D") Or (Left(Me.txtname, 1) = "E") Then
With Application.FileSearch 'Searchs D drive
.LookIn = "D" & Right(Filefolder, Len(Filefolder) - 1)
.SearchSubFolders = False
.Filename = Filename
.MatchTextExactly = True
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
If Len(Mid(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)) = Len(Filename) Then
Me.Image.Picture = .FoundFiles(i)
End If
Next
End If
s = .FoundFiles.Count
End With
If s = 0 Then
With Application.FileSearch 'Searchs E drive
.LookIn = "E" & Right(Filefolder, Len(Filefolder) - 1)
.SearchSubFolders = False
.Filename = Filename
.MatchTextExactly = True
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
If Len(Mid(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)) = Len(Filename) Then
Me.Image.Picture = .FoundFiles(i)
End If
Next
End If
t = .FoundFiles.Count
If t = 0 Then
Dim reply As Integer
reply = MsgBox("Please insert picture CD", vbOKCancel, "Please insert picture CD")
'2 = Cancel; 1 = Ok;
If reply = 2 Then
Me.Image.Picture = ""
Else
If reply = 1 Then ' I what it to go up to the top line
End If
End If
End With
End If
Else: Me.Image.Picture = Me.txtname
End If
End If
End Sub
Private Sub Form_Current()
Dim WholeSpec As String
Dim Filefolder As String
Dim Filename As String
Dim s As String
Dim i As Integer
If IsNull(Me.txtname) Then
Me.Image.Picture = "" 'No image
Else:
WholeSpec = Me.txtname
Filefolder = Mid(WholeSpec, 1, InStrRev(WholeSpec, "\") - 1)
Filename = Mid(WholeSpec, InStrRev(WholeSpec, "\") + 1)
If (Left(Me.txtname, 1) = "D") Or (Left(Me.txtname, 1) = "E") Then
With Application.FileSearch 'Searchs D drive
.LookIn = "D" & Right(Filefolder, Len(Filefolder) - 1)
.SearchSubFolders = False
.Filename = Filename
.MatchTextExactly = True
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
If Len(Mid(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)) = Len(Filename) Then
Me.Image.Picture = .FoundFiles(i)
End If
Next
End If
s = .FoundFiles.Count
End With
If s = 0 Then
With Application.FileSearch 'Searchs E drive
.LookIn = "E" & Right(Filefolder, Len(Filefolder) - 1)
.SearchSubFolders = False
.Filename = Filename
.MatchTextExactly = True
If .Execute() > 0 Then
For i = 1 To .FoundFiles.Count
If Len(Mid(.FoundFiles(i), InStrRev(.FoundFiles(i), "\") + 1)) = Len(Filename) Then
Me.Image.Picture = .FoundFiles(i)
End If
Next
End If
t = .FoundFiles.Count
If t = 0 Then
Dim reply As Integer
reply = MsgBox("Please insert picture CD", vbOKCancel, "Please insert picture CD")
'2 = Cancel; 1 = Ok;
If reply = 2 Then
Me.Image.Picture = ""
Else
If reply = 1 Then ' I what it to go up to the top line
End If
End If
End With
End If
Else: Me.Image.Picture = Me.txtname
End If
End If
End Sub