Thanks for the reply RuralGuy,
Worked it out just before your reply.
Just wondering. I am using the following code that I was very pleased to obtain from the site. Credit to the writer.
As you can see I am using four sets of the Two buttons and text box on the same form.
Is there a way to merge all four sets of the code to make it smaller or will it be ok like it is
h
Private Sub cmdOpenDialog1_Click()
Dim strPath As String
'Make a search string for the type of file you want to select
'Examples:
'Excel Files & All Files... CDSearchString = MakeFilterString("Excel Files (*.xls)", "*.xls", "All Files (*.*)", "*.*")
'Word Files... CDSearchString = MakeFilterString("Word Documents (*.doc)", "*.doc", "Text Files (*.txt)", "*.txt", "All Files (*.*)", "*.*")
'Graphic Files... CDSearchString = MakeFilterString("Graphic Files (*.bmp;*.gif;*.jpg;*.wmf)", "*.bmp;*.gif;*.jpg;*.wmf")
CDSearchString = MakeFilterString("All Files (*.*)", "*.*")
'Set the Caption on the Dialog Box
CDCaption = "Select File to Attach..."
If IsNull([Contract]) Or Me.Contract = "" Then
CDInitDir = "C:\"
Else
CDInitDir = [Contract]
End If
strPath = LaunchCD(Me)
If Not strPath = "None Selected" Then
Me.Contract = strPath
End If
End Sub
Private Sub cmdPreview1_Click()
On Error GoTo Err_bOpen_Click
If IsNull(Contract) Or Contract = "" Then
MsgBox "Please browse and select a valid file to open.", vbCritical, "Invalid File"
Else
OpenFile (Contract)
End If
Exit_bOpen_Click:
Exit Sub
Err_bOpen_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_bOpen_Click
End Sub
Private Sub cmdOpenDialog2_Click()
Dim strPath As String
'Make a search string for the type of file you want to select
'Examples:
'Excel Files & All Files... CDSearchString = MakeFilterString("Excel Files (*.xls)", "*.xls", "All Files (*.*)", "*.*")
'Word Files... CDSearchString = MakeFilterString("Word Documents (*.doc)", "*.doc", "Text Files (*.txt)", "*.txt", "All Files (*.*)", "*.*")
'Graphic Files... CDSearchString = MakeFilterString("Graphic Files (*.bmp;*.gif;*.jpg;*.wmf)", "*.bmp;*.gif;*.jpg;*.wmf")
CDSearchString = MakeFilterString("All Files (*.*)", "*.*")
'Set the Caption on the Dialog Box
CDCaption = "Select File to Attach..."
If IsNull([OldMap]) Or Me.OldMap = "" Then
CDInitDir = "C:\"
Else
CDInitDir = [OldMap]
End If
strPath = LaunchCD(Me)
If Not strPath = "None Selected" Then
Me.OldMap = strPath
End If
End Sub
Private Sub cmdPreview2_Click()
On Error GoTo Err_bOpen_Click
If IsNull(OldMap) Or OldMap = "" Then
MsgBox "Please browse and select a valid file to open.", vbCritical, "Invalid File"
Else
OpenFile (OldMap)
End If
Exit_bOpen_Click:
Exit Sub
Err_bOpen_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_bOpen_Click
End Sub
Private Sub cmdOpenDialog3_Click()
Dim strPath As String
'Make a search string for the type of file you want to select
'Examples:
'Excel Files & All Files... CDSearchString = MakeFilterString("Excel Files (*.xls)", "*.xls", "All Files (*.*)", "*.*")
'Word Files... CDSearchString = MakeFilterString("Word Documents (*.doc)", "*.doc", "Text Files (*.txt)", "*.txt", "All Files (*.*)", "*.*")
'Graphic Files... CDSearchString = MakeFilterString("Graphic Files (*.bmp;*.gif;*.jpg;*.wmf)", "*.bmp;*.gif;*.jpg;*.wmf")
CDSearchString = MakeFilterString("All Files (*.*)", "*.*")
'Set the Caption on the Dialog Box
CDCaption = "Select File to Attach..."
If IsNull([ModernMap]) Or Me.ModernMap = "" Then
CDInitDir = "C:\"
Else
CDInitDir = [ModernMap]
End If
strPath = LaunchCD(Me)
If Not strPath = "None Selected" Then
Me.ModernMap = strPath
End If
End Sub
Private Sub cmdPreview3_Click()
On Error GoTo Err_bOpen_Click
If IsNull(ModernMap) Or ModernMap = "" Then
MsgBox "Please browse and select a valid file to open.", vbCritical, "Invalid File"
Else
OpenFile (ModernMap)
End If
Exit_bOpen_Click:
Exit Sub
Err_bOpen_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_bOpen_Click
End Sub
Private Sub cmdOpenDialog4_Click()
Dim strPath As String
'Make a search string for the type of file you want to select
'Examples:
'Excel Files & All Files... CDSearchString = MakeFilterString("Excel Files (*.xls)", "*.xls", "All Files (*.*)", "*.*")
'Word Files... CDSearchString = MakeFilterString("Word Documents (*.doc)", "*.doc", "Text Files (*.txt)", "*.txt", "All Files (*.*)", "*.*")
'Graphic Files... CDSearchString = MakeFilterString("Graphic Files (*.bmp;*.gif;*.jpg;*.wmf)", "*.bmp;*.gif;*.jpg;*.wmf")
CDSearchString = MakeFilterString("All Files (*.*)", "*.*")
'Set the Caption on the Dialog Box
CDCaption = "Select File to Attach..."
If IsNull([FieldNoMap]) Or Me.FieldNoMap = "" Then
CDInitDir = "C:\"
Else
CDInitDir = [FieldNoMap]
End If
strPath = LaunchCD(Me)
If Not strPath = "None Selected" Then
Me.FieldNoMap = strPath
End If
End Sub
Private Sub cmdPreview4_Click()
On Error GoTo Err_bOpen_Click
If IsNull(FieldNoMap) Or FieldNoMap = "" Then
MsgBox "Please browse and select a valid file to open.", vbCritical, "Invalid File"
Else
OpenFile (FieldNoMap)
End If
Exit_bOpen_Click:
Exit Sub
Err_bOpen_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_bOpen_Click
End Sub