Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error:2450

Status
Not open for further replies.

Kanaga7

Programmer
Feb 3, 2004
5
US
Hi,

When I click cancel button in the report, i got the following msg "Run-time error 2450: can't find the form ..referred to in a macro expression or visual basic code".
My code:
Private Sub cmdCancel_Click()
If Left(Me.OpenArgs, 12) = "frmACAddEdit" Then
SelectIt Forms(Me.OpenArgs)!txtAttorneySSN -->error in
this line
End If
Forms(Me.OpenArgs).Visible = True
DoCmd.Close acForm, Me.Name
End Sub
 
Hi!

Try:
[tt]Forms(Me.OpenArgs)("txtAttorneySSN")[/tt]

Roy-Vidar
 
Hi Roy,

Thanks for your response. But still I'm getting the same error. Can you help me fix it. It says it couldn't find that form in the database. But that form is in the database.
Thanks,
 
In the if test you use the left function on the openargs, but you do not use that when you try to use the "SelectIt" sub. Try that, in case you have some other values or spaces within your openargs.

Else, provide more information, current code, full errormsg...

Roy-Vidar
 
Thanks Roy,

The values(form name) I'm getting in openargs is in that database. But still I'm getting error. I hope this form may be closed anywhereelse.

Error:

Run-time error'2450':
Database can't find the form'...' referred to in a macro expression or visual basic code.
*the form you referenced may be closed or may not exist in the database.
*database may have encountered a compile error in a visual basic module of the form.

Thanks
 
Is form "frmACAddEdit" by any chance, a subform?

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Yes the form must be open to reference a control on it. Have you tried some of my previous suggestions? Try also the one where I suggested to post also the current code.

If establishing whether the form is open or not also is an issue, try for instance the isloaded function in Rohdems faq faq181-320 (paste it into a module, and use it to test if the form is loaded)

Roy-Vidar
 
Hi,
the code is

Private Sub cmdCancel_Click()
'Test
MsgBox (Me.OpenArgs)
If Left(Me.OpenArgs, 12) = "frmACAddEdit" Then
SelectIt Forms(Me.OpenArgs)!txtAttorneySSN
End If
Forms(Me.OpenArgs).Visible = True
DoCmd.Close acForm, Me.Name
End Sub

Here Me.OpenArgs = frmACAddEditAssignedCounsel
this form is in the database.
The above code is for the form "frmACAttorneyDataSheet".

For example,
Control from form1 goes to form2, when we cancel form2 , the control goes to form3, when we cancel or click any button in form3, it gives error as "cannot find the form form2".

Thanks
 
If you're using the same code in all forms, you've answered your own question, you close the calling form when you cancel. Form2 is closed when you attempt to "SelectIt", which is giving the error.

What you probably need, is the isloaded function i mentioned in previous post, and then some code perhaps like this, to ensure the form is open.

[tt]If Not IsLoaded(Me.OpenArgs) Then
Docmd.OpenForm Me.OpenArgs ' add your preferred arguments...
End If
SelectIt Forms(Me.OpenArgs)("txtAttorneySSN")
...[/tt]

Roy-Vidar
 
Hi,

I tried this. But wherever "Me.openArgs" i.e. to access the form 'frmACAddEditAssignedCounsel'. It is giving error 2450.
Codes are not same for all forms, they r different.
form1 to form2 ,then form3. In form3, when we click any of the button(that access variables from form2), it is giving error.
 
ARE THE ACTUAL FORMS OPEN WHEN YOU TRY TO ACCESS THEM???

From the code, it seems you close them.

Why do you use the left function only the check the what's wihtin the openargs and not when you use the openargs to access the form? Is there a possibility of having more charachters than the form name within openargs? If so, use the left function elsewhere too, or perhaps assign the relevant part of the openargs to a variable, and use that.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top