OpenArgs do not pass info

G

Guest

After reading a number of posts on OpenArgs, it seem that there is some
problems with it but it seems everybody got their respective codes to work in
the end.

I couldn't however! What am I doing wrong?

In my switchboard I have two buttons that are used to open the same form,
but to do different things.

I need to pass a variable to the form, so that the form can behave
accordingly (change labels, hide certain objects etc.)

Behind my first button, the code reads:

DoCmd.OpenForm stDocName, , , "Complete = false", , , "State1"

the other calls

DoCmd.OpenForm stDocName, , , "Complete = true", , , "State2"

Now, in my form open routine, I need to setup the form accordingly, but my
OpenArgs values aren't passed!!!!

Private Sub Form_Open(Cancel As Integer)

Dim test As String
test = Me.OpenArgs

in my case, Me.OpenArgs is NULL, and produces an error on this statement!!

I then tried ommiting the OpenArgs variable and used (also in the open_form
sub) the following:

Select Case Me.Filter
Case "Complete = FALSE"
ToggleAndSetFilter.Visible = False
Case "Complete = TRUE"
ToggleAndSetFilter.Caption = "These records are completed"
ToggleAndSetFilter.ForeColor = 32768
End Select

For some reason, the value of Me.Filter is also not correct when the form is
opened, eventhough the correct records are shown. I assume the filter
arguement is passed later and not yet set when the OPEN FORM sub is called.

But then, why doesn't OpenArgs pass the variable?? Am I missing something
stupid?
 
A

Allen Browne

Paul, is the form actually open when you run this code?

If so, it will retain the OpenArgs from when it was originally opened, and
so the new value is not used. That's true even if the report was open in
design view.

The same holds true for reports.
 
G

Guest

Aaarg!!! Man, thanks! Yes, I was testing it so the design view stayed open
all the time! It is these little things that can cause so much trouble!!!
 

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