G
Guest
Having a couple related problems with some VB code I inherited.
1) I have a form (frmCALLED) that is called from two different forms
(frmSOURCE1 and frmSOURCE2) within a database.
2) This same form (frmCALLED) when exiting opens frmSOURCE1 even when
frmSOURCE2 was the calling form and should be returned to that form.
frmCALLED works just fine when called from frmSOURCE1, but when called by
frmSOURCE2 it errors out. I believe that it is in the code behind frmCALLED
where it is trying to populate a VALUE from frmSOURCE1 and the error happens
when it is called by frmSOURCE2 because the frmSOURCE1.user.VALUE does not
exist, but frmSOURCE2.user.value does exist.
*********************** SAMPLE CODE ********************
Private Sub Form_Load()
User.Value = Forms![frmSOURCE1]![User]
End Sub
Private Sub cmdSubmit_Click()
On Error GoTo Err_cmdSubmit_Click
Submitted.Value = True
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSOURCE1"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdSubmit_Click:
Exit Sub
Err_cmdSubmit_Click:
MsgBox Err.Description
Resume Exit_cmdSubmit_Click
End Sub
Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click
DoCmd.Close
DoCmd.OpenForm "frmSOURCE1"
Exit_cmdExit_Click:
Exit Sub
Err_cmdExit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click
End Sub
********************* END OF SAMPLE ******************
While I could replicate the form and its associated code and rename it for
the specific form/function it is responding to, I would like to make the one
instance of this code "more intelligent" and able to handle multiple source
calls provided the variable User.Value is available from the new source
subroutine.
In a nutshell, is there a simple way to make this code "smart" enough to know:
A) WHICH frmSOURCE# called it;
B) To gather the correct frmSOURCE#.User.VALUE; and
C) To return to the correct frmSOURCE# on exit?
Thank you in advance for your support and assistance.
Sincerely,
MJ
1) I have a form (frmCALLED) that is called from two different forms
(frmSOURCE1 and frmSOURCE2) within a database.
2) This same form (frmCALLED) when exiting opens frmSOURCE1 even when
frmSOURCE2 was the calling form and should be returned to that form.
frmCALLED works just fine when called from frmSOURCE1, but when called by
frmSOURCE2 it errors out. I believe that it is in the code behind frmCALLED
where it is trying to populate a VALUE from frmSOURCE1 and the error happens
when it is called by frmSOURCE2 because the frmSOURCE1.user.VALUE does not
exist, but frmSOURCE2.user.value does exist.
*********************** SAMPLE CODE ********************
Private Sub Form_Load()
User.Value = Forms![frmSOURCE1]![User]
End Sub
Private Sub cmdSubmit_Click()
On Error GoTo Err_cmdSubmit_Click
Submitted.Value = True
DoCmd.Close
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSOURCE1"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdSubmit_Click:
Exit Sub
Err_cmdSubmit_Click:
MsgBox Err.Description
Resume Exit_cmdSubmit_Click
End Sub
Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Click
DoCmd.Close
DoCmd.OpenForm "frmSOURCE1"
Exit_cmdExit_Click:
Exit Sub
Err_cmdExit_Click:
MsgBox Err.Description
Resume Exit_cmdExit_Click
End Sub
********************* END OF SAMPLE ******************
While I could replicate the form and its associated code and rename it for
the specific form/function it is responding to, I would like to make the one
instance of this code "more intelligent" and able to handle multiple source
calls provided the variable User.Value is available from the new source
subroutine.
In a nutshell, is there a simple way to make this code "smart" enough to know:
A) WHICH frmSOURCE# called it;
B) To gather the correct frmSOURCE#.User.VALUE; and
C) To return to the correct frmSOURCE# on exit?
Thank you in advance for your support and assistance.
Sincerely,
MJ