R
RLN
I inherited an application that has lots of duplicate code in it.
The code below is for two separate buttons on a form, each one opens a
different form. Is there a way to have one module that could pass in the
form? Do you pass in the form as a string, an object or as a form? I tried
several an received errors. I think I'm on the right track, just have the
wrong syntax.
Thanks.
Code:
Private Sub cmdW1Data_Click()
On Error GoTo Err1
DoCmd.OpenForm "frmW1DataOut", acFormDS 'acFormDS = Datasheet mode
Exit1:
Exit Sub
Err1:
UTIL_ErrorMessage Err.Number, _
Err.Description, _
"There was a problem viewing the output data
for W1.", _
"cmdW1Data_Click()"
Resume Exit1
End Sub
Private Sub cmdW2Data_Click()
On Error GoTo Err1
DoCmd.OpenForm "frmW2DataOut", acFormDS
Exit1:
Exit Sub
Err1:
UTIL_ErrorMessage Err.Number, _
Err.Description, _
"There was a problem viewing the output data
for W2.", _
"cmdW2Data_Click()"
Resume Exit1
End Sub
The code below is for two separate buttons on a form, each one opens a
different form. Is there a way to have one module that could pass in the
form? Do you pass in the form as a string, an object or as a form? I tried
several an received errors. I think I'm on the right track, just have the
wrong syntax.
Thanks.
Code:
Private Sub cmdW1Data_Click()
On Error GoTo Err1
DoCmd.OpenForm "frmW1DataOut", acFormDS 'acFormDS = Datasheet mode
Exit1:
Exit Sub
Err1:
UTIL_ErrorMessage Err.Number, _
Err.Description, _
"There was a problem viewing the output data
for W1.", _
"cmdW1Data_Click()"
Resume Exit1
End Sub
Private Sub cmdW2Data_Click()
On Error GoTo Err1
DoCmd.OpenForm "frmW2DataOut", acFormDS
Exit1:
Exit Sub
Err1:
UTIL_ErrorMessage Err.Number, _
Err.Description, _
"There was a problem viewing the output data
for W2.", _
"cmdW2Data_Click()"
Resume Exit1
End Sub