INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Runtime error:2450

Runtime error:2450

(OP)
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

RE: Runtime error:2450

Hi!

Try:
Forms(Me.OpenArgs)("txtAttorneySSN")

Roy-Vidar

RE: Runtime error:2450

(OP)
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,

RE: Runtime error:2450

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

RE: Runtime error:2450

(OP)
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

RE: Runtime error:2450

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

RE: Runtime error:2450

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

RE: Runtime error:2450

(OP)
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

RE: Runtime error:2450

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.

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


Roy-Vidar

RE: Runtime error:2450

(OP)
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.

RE: Runtime error:2450

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close