473,320 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

error message when using openargs

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
4 2098
beacon
579 512MB
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
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
Stewart Ross
2,545 Expert Mod 2GB
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
579 512MB
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

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

Similar topics

2
by: ColinWard | last post by:
whenever I run the following code I get an error saying that 'Trade Show and Conference Contacts database could not find the form 'Events_Form' referred to in a macro or in Visual Basic Code. The...
5
by: David Deacon | last post by:
Hi i have the following code in a CustomerID field if the user enters a notinlist customer then they should dbl click to open the customer form However this error occurs "You tried to assign a...
0
by: NOSPAM | last post by:
Guys, I get the 'There was an error executing the command' error message. I an using win xp & Access 2002. I created a database using the MS Access template 'Order Entry' I have entered...
5
by: jannordgreen | last post by:
The form 'Client Records' has this record source: SELECT ., .LastName, .FirstName, .Company, .Address, .City, ., .State, .Country, .WorkPhone, .FaxNumber, .EmailAddress, .Business, .Origin, .,...
4
by: Keith | last post by:
I have the following code in the On No Data event of a report: **** On Error GoTo err_trap MsgBox "No items matching criteria.", vbInformation, gcApplication Cancel = True err_trap: If...
2
by: MLH | last post by:
I have the following code with a SendKeys statement in it. 100 If Me.Dirty Then MsgBox "Form is Dirty!" 120 Dim MyQ As String, MyTitle As String, Response As Boolean 140 MyQ =...
1
by: sumit205 | last post by:
Error 2467:The Expression you entered refers to an object that is closed or doesn't exist . DoCmd.OpenForm frm2, WindowMode:=acDialog, OpenArgs:="c" & NewProductID In the debig mode when i...
3
by: angi35 | last post by:
I'm having a zero-length string problem... Hoping someone can help. (This is in Access 2000.) In FormA, I have a button that opens FormB with OpenArgs. In FormB, the OpenArgs are translated into...
2
by: sphinney | last post by:
Hi everyone. I have a form in my Access 2007 database with a Microsoft Office Document Imaging Viewer Control 12.0 object on it. The object is named "GRAPHIC_mdv". When the form opens I want to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.