By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,122 Members | 927 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,122 IT Pros & Developers. It's quick & easy.

error message when using openargs

P: 47
I'm trying to use docmd.openform, passing a parameter using openargs. I keep getting this error message:

"The expression you entered refers to an object that is closed or doesn't exist."

The problem is, everything in this command DOES exist.

Here's my code.
DoCmd.OpenForm stDocName, , , , , , Me.MemID

Anyone have ideas? Please!


Dante
Dec 16 '08 #1
Share this Question
Share on Google+
4 Replies


beacon
100+
P: 579
Hi Dante,

I could be wrong about this, but is the form where the parameter is located open?

I think that if you don't set the field equal to a parameter, the form actually has to be open in order to pass the argument.

I would try the following:
Expand|Select|Wrap|Line Numbers
  1. myParameter = Me.MemID.Value
  2.  
  3. DoCmd.OpenForm stDocumentName, , , , , myParameter
  4.  
Using a field on a closed form could especially be the problem if you included a DoCmd.Close immediately before the DoCmd.OpenForm.

Like I said, I could be wrong about this, but I swear I've run across this somewhere in this forum.

Hope it helps, nonetheless

- beacon
Dec 16 '08 #2

P: 47
Thanks Beacon.

The script closes the form before it tries to set the parameter.

Now to see if I can get the d--n thing to USE the parameter. Stay tuned.


Dante
Dec 16 '08 #3

Expert Mod 2.5K+
P: 2,545
Hi Beacon. The OpenForm method is intended to open a form that is currently closed, and it will indeed pass whatever argument is passed to OpenArgs on form open, so it is not the status of the form itself that is the problem (at least on that code line).

I'd suggest first checking that the name of the form within string variable stDocName is correctly set. Failing that, check that the control you are referring to as your parameter actually exists and is correctly named. If in doubt remove the parameter and try the code without it.

OpenArgs is just a means to pass values to a form; it is very forgiving about what you pass to it, so this whole problem appears to come down to errors in either the name of the form to open or the name of the control passed to OpenArgs.

-Stewart

Ahh, I posted before seeing your last update - so the form is being closed before it gets the chance to pass the argument - OK! In my test setup this did not prevent OpenArgs from working, but I guess it depends on the circumstances in your own case. Well done for resolving it yourself with Beacon's assistance.
Dec 16 '08 #4

beacon
100+
P: 579
Hi Stewart,

I didn't have the problem, but thank you for explaining it and correcting what I originally told Dante. I know Dante will appreciate it.

Thanks,
beacon
Dec 16 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.