openargs is null at called form

B

BobD

In access 2003, I'm opening a form using the docmd.openform command and
passing a long integer value to the called form. In debug mode, the value of
the openargs parameter is correct. When I try to use the value in the called
form, like lngValue = me.openargs, the value of openargs shows up as null. I
just switched to 2003 from XP, and I don't recall seeing this problem before.
 
A

Allen Browne

Any chance the form is already open when you OpenForm with the OpenArgs?

If so, it retains the OpenArgs from when it was acutally opened.
You may need to test like this:
Dim strDoc as String
strDoc = "Form1"
If CurrentProject.AllForms(strDoc).IsLoaded Then
with Forms(strDoc)
If .Dirty Then .Dirty = False
DoCmd.Close acForm, strDoc
End With
End If
DoCmd.OpenForm strDoc, OpenArgs:="99"
 
B

BobD

I had the called form open in design view. By closing it entirely, the code
started working ok. Thanks for the suggestion
 

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