OPENARGS problem

B

Biggles

When I try to click on the button3 (code below), that calls the openfrm and
opens the correct form, but I get an error message in the on_open event of
sfrmca_selectapps in the code line, invalid use of null:

FLAG = Right$(Me.OpenArgs, 1)

When I eliminate the call openfrm from the button3_on_click, it seems to
work (and moves to another error, which will be another question
momentarily), but with the large number of buttons to open forms, I want to
consolidate the code.

Any ideas? Thanks

FROM MY DASHBOARD FORM

Public Sub OPENFRM()

DoCmd.OpenForm "SFRMCA_SELECTAPPS", acNormal, , , , , stdocname
Forms!SFRMCA_SELECTAPPS!Command11.Visible = True

End Sub

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stdocname As String

stdocname = "frmCA_ADD_IDEA0"
'Call OPENFRM
DoCmd.OpenForm "SFRMCA_SELECTAPPS", acNormal, , , , , stdocname
Forms!SFRMCA_SELECTAPPS!Command11.Visible = True


Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

FROM THE TARGET FORM

Private Sub Form_Open(Cancel As Integer)
Dim FLAG As String

FLAG = Right$(Me.OpenArgs, 1)

If FLAG = 0 Then
Me.Option7.Visible = False
Me.Label8.Visible = False
Me.Label0.Caption = "SELECT ONE APPLICATION"
Me.Selectapp.MultiSelect = 0
Else
Me.Option7.Visible = True
Me.Label8.Visible = True
Me.Label0.Caption = "Select multiple applications or choose All
Applications"
Me.Selectapp.MultiSelect = 1
End If

End Sub
 
D

Dirk Goldgar

Biggles said:
When I try to click on the button3 (code below), that calls the
openfrm and opens the correct form, but I get an error message in the
on_open event of sfrmca_selectapps in the code line, invalid use of
null:

FLAG = Right$(Me.OpenArgs, 1)

When I eliminate the call openfrm from the button3_on_click, it seems
to work (and moves to another error, which will be another question
momentarily), but with the large number of buttons to open forms, I
want to consolidate the code.

Any ideas? Thanks

FROM MY DASHBOARD FORM

Public Sub OPENFRM()

DoCmd.OpenForm "SFRMCA_SELECTAPPS", acNormal, , , , , stdocname
Forms!SFRMCA_SELECTAPPS!Command11.Visible = True

End Sub

Private Sub Command3_Click()
On Error GoTo Err_Command3_Click

Dim stdocname As String

stdocname = "frmCA_ADD_IDEA0"
'Call OPENFRM
DoCmd.OpenForm "SFRMCA_SELECTAPPS", acNormal, , , , , stdocname
Forms!SFRMCA_SELECTAPPS!Command11.Visible = True


Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click

End Sub

FROM THE TARGET FORM

Private Sub Form_Open(Cancel As Integer)
Dim FLAG As String

FLAG = Right$(Me.OpenArgs, 1)

If FLAG = 0 Then
Me.Option7.Visible = False
Me.Label8.Visible = False
Me.Label0.Caption = "SELECT ONE APPLICATION"
Me.Selectapp.MultiSelect = 0
Else
Me.Option7.Visible = True
Me.Label8.Visible = True
Me.Label0.Caption = "Select multiple applications or choose
All Applications"
Me.Selectapp.MultiSelect = 1
End If

End Sub

If you're saying that it's the OPENFRM sub that gives the error:
Public Sub OPENFRM()

DoCmd.OpenForm "SFRMCA_SELECTAPPS", acNormal, , , , , stdocname
Forms!SFRMCA_SELECTAPPS!Command11.Visible = True

End Sub

.... that would be because there is nothing in that procedure that
defines or sets a value for stdocname. You need to modify it to include
these lines that you have in your Command3_Click procedure:
Dim stdocname As String

stdocname = "frmCA_ADD_IDEA0"

It would also be a good idea for you to modify the code in the target
form's Open event so that it copes gracefully if no OpenArgs was passed.
Instead of this:
FLAG = Right$(Me.OpenArgs, 1)

If FLAG = 0 Then

.... you might have something like this:

FLAG = Right$(Me.OpenArgs & "", 1)

If FLAG = "0" Then

The concatenation with "" will convert a Null, if passed, into a
zero-length string. I changed the If statement so that you are
comparing FLAG to a string literal, so now if FLAG is "" you won't get
an error.
 

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