Run-time error '2467' with OpenArgs

J

Judy Ward

I want to click a button on one form (frmDSSF), open another form
(frmDSSF_Subcontractor) and pass a value to it (DSSF_ID).

I have used a Debug.Print to make sure the Me.DSSF_ID has a value.
I can open the form using: DoCmd.OpenForm "frmDSSF_Subcontractor"

In the click event of the button on frmDSSF I am I have tried:
DoCmd.OpenForm "frmDSSF_Subcontractor", OpenArgs:=Me.DSSF_ID
DoCmd.OpenForm "frmDSSF_Subcontractor", , , , , , Me.DSSF_ID

I get Run-time error '2467':
The expression you entered refers to an object that is closed or doesn't
exist.

The object does exist. The form is closed. I thought DoCmd.OpenForm was
supposed to open it!

Any help with this would be appreciated.

Thank you,
Judy
 
J

Judy Ward

I figured out what I was doing wrong. In between the Debug.Print statement
(proving that Me.DSSF_ID had a value) and the DoCmd.OpenForm I was calling a
subroutine which closed frmDSSF. Since my code was halting, I never even
noticed that frmDSSF was being closed. Now that I am not closing frmDSSF,
the command works.

Problem solved!
 
M

missinglinq via AccessMonster.com

Hey, Judy!

Your first attempt to open the frmDSSF_Subcontractor

DoCmd.OpenForm "frmDSSF_Subcontractor", OpenArgs:=Me.DSSF_ID

is incorrect, but

DoCmd.OpenForm "frmDSSF_Subcontractor", , , , , , Me.DSSF_ID

is right and should work. With no more code than you've shown here, I'm just
guessing here, but my guess would be that somewhere in the unshown code
you've closed frmDSSF before the openargs can be passed. If this is so, you
need to move your code for closing frmDSSF to after the line opening
frmDSSF_Subcontractor.

Good luck!
 
M

missinglinq via AccessMonster.com

You got there ahead of me! I started typing my answer and my Black Lab, Puck
the Magic Chow Hound, came in and insisted we go for a walk! By the time I
got back and hit Send you'd already found the problem! We're always here to
help, but it's good to figure out the answer for yourself!

Good Luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top