Call Function MS Access 2003

Get help on databases - MySQL, Oracle, Access, etc.
Post Reply
Mclaren
Registered User
Posts: 497
Joined: 30 Apr 2007, 02:00
Location: c:\program files\temp
Contact:

Call Function MS Access 2003

Post by Mclaren »

Hi, I have a button on a form A (frm_Jobs) which once clicked, and depending on certain criteria will open an overide prompt (frm_Overide) . Once the overide has been confirmed a variable is set to 1 and the overide form closes and calls the same button on Form A again. The code for the button on Form A checks the variable and executes code depending on whether the variable is set to 1 or 0. the problem is : Different forms may need to call the same Overide prompt form. so, I have set 2 global variables to cater for form name and control name of Form A. i.e strFormName and strControlName. the values for these variables are set when i originally action the button on Form A

The control on form A is a public control so the call funtion works great if i use the actual form name and control name in my call statement i.e. Forms!frm_Job.cmd_Re_Open_Click

what i want to be able to do is use the following function

Forms!strFormName.strControlName

if i use the above i get the following error:

Run-time error '2450':

Can't find the form 'strformname' refered to in a macro
expression or Visual Basic code.

please can anyone help.

code for form A is:

Public Sub cmd_Re_Open_Click()
On Error GoTo Err_cmd_Re_Open_Click

If vOverideConfirm = 1 Then
Me.Completed = False
Me.Form.AllowEdits = True
Me.frm_Jobs_Details_subform.Form.AllowEdits = True
vOverideConfirm = 0
Else
strFormName = "frm_Jobs"
strControlName = "cmd_Re_Open_Click"
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_Overide"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Exit_cmd_Re_Open_Click:
Exit Sub

Err_cmd_Re_Open_Click:
MsgBox Err.Description
Resume Exit_cmd_Re_Open_Click

End Sub

Relevant Code for Overide form is :

vOverideConfirm = 1
DoCmd.Close acForm, "frm_Overide", acSaveNo
Forms!strFormName.strControlName
Post Reply