How to send Option Group Info to New Form OpenArgs?

D

dohernan

I have a form in access 2003 with a button that opens up another form in
Datasheet view. Before people view the spreadsheet, I want them to choose
how to sort it.
I did an Options Group with 3 choices.

I don't know how to feed these options to the opening Form/Spreadsheet...
"Pass the value selected in the option group to the new form in the OpenArgs
argument of the OpenForm method."

Help please? Thanks.

Klatuu was kind enough to say-
In the Load event of the datasheet form, set the form's Order By property
using the value received in the option group.

If Not IsNull(Me.OpenArgs) Then
Select Case Me.OpenArgs
Case 1
Me.OrderBy = "[Last name], [First name], [date received]"
Case 2
Me.OrderBy = "[date received].[Last name], [First name]"
Case 3
Me.OrderBy = "[date completed].[Last name], [First name]"
End Select
End If
 
M

Marshall Barton

dohernan said:
I have a form in access 2003 with a button that opens up another form in
Datasheet view. Before people view the spreadsheet, I want them to choose
how to sort it.
I did an Options Group with 3 choices.

I don't know how to feed these options to the opening Form/Spreadsheet...
"Pass the value selected in the option group to the new form in the OpenArgs
argument of the OpenForm method."

Klatuu was kind enough to say-
In the Load event of the datasheet form, set the form's Order By property
using the value received in the option group.

If Not IsNull(Me.OpenArgs) Then
Select Case Me.OpenArgs
Case 1
Me.OrderBy = "[Last name], [First name], [date received]"
Case 2
Me.OrderBy = "[date received].[Last name], [First name]"
Case 3
Me.OrderBy = "[date completed].[Last name], [First name]"
End Select
End If


In the button;s Click event, change the line that opens the
other form to this kind of thing:

SoCmd.OpenForm . . . , OpenArgs:=Me.theoptiongroup
 
D

dohernan via AccessMonster.com

It gives me the error that it expects brackets?

Private Sub CommandViewSpreadsheet_Click()
On Error GoTo Err_CommandViewSpreadsheet_Click

Dim stDocName As String

stDocName = "Personnel2009Spreadsheet"
SoCmd.OpenForm stDocName, acFormDS. . . , OpenArgs:=Me.
spreadsheetoptiongroup


Exit_CommandViewSpreadsheet_Click:
Exit Sub

Err_CommandViewSpreadsheet_Click:
MsgBox Err.Description
Resume Exit_CommandViewSpreadsheet_Click

End Sub

Thanks :)



Marshall said:
I have a form in access 2003 with a button that opens up another form in
Datasheet view. Before people view the spreadsheet, I want them to choose
[quoted text clipped - 19 lines]
End Select
End If

In the button;s Click event, change the line that opens the
other form to this kind of thing:

SoCmd.OpenForm . . . , OpenArgs:=Me.theoptiongroup
 
D

Damon Heron

I answered this question in another thread, but here goes again:

DoCmd.OpenForm stDocName, , , , , ,me.[yourframename].value

This passes the value of your option frame as an openarg to the new form.
Using Klatu's code, the value of the passed openarg is used to order the
form's data.

DAMON

dohernan via AccessMonster.com said:
It gives me the error that it expects brackets?

Private Sub CommandViewSpreadsheet_Click()
On Error GoTo Err_CommandViewSpreadsheet_Click

Dim stDocName As String

stDocName = "Personnel2009Spreadsheet"
SoCmd.OpenForm stDocName, acFormDS. . . , OpenArgs:=Me.
spreadsheetoptiongroup


Exit_CommandViewSpreadsheet_Click:
Exit Sub

Err_CommandViewSpreadsheet_Click:
MsgBox Err.Description
Resume Exit_CommandViewSpreadsheet_Click

End Sub

Thanks :)



Marshall said:
I have a form in access 2003 with a button that opens up another form in
Datasheet view. Before people view the spreadsheet, I want them to
choose
[quoted text clipped - 19 lines]
End Select
End If

In the button;s Click event, change the line that opens the
other form to this kind of thing:

SoCmd.OpenForm . . . , OpenArgs:=Me.theoptiongroup
 
M

Marshall Barton

dohernan said:
It gives me the error that it expects brackets?

Private Sub CommandViewSpreadsheet_Click()
On Error GoTo Err_CommandViewSpreadsheet_Click

Dim stDocName As String

stDocName = "Personnel2009Spreadsheet"
SoCmd.OpenForm stDocName, acFormDS. . . , OpenArgs:=Me.
spreadsheetoptiongroup

Exit_CommandViewSpreadsheet_Click:
Exit Sub


When you post code, please use Copy/Paste of your actual
code so we don't waste time going back and forth dealing
with typos.

If you did use Copy/Paste, then you should use the Debug -
Compile menu item to check your code before trying to run
it. If you had done that, the misspelled DoCmd and the ...
is used would have been obvious things to fix.
 
D

dohernan via AccessMonster.com

Thank you! I got it to work in datasheet view like this-

Private Sub CommandViewSpreadsheet_Click()
On Error GoTo Err_CommandViewSpreadsheet_Click

Dim stDocName As String
Dim i As Integer
i = Me.SpreadsheetOptionGroup

stDocName = "Personnel2009Spreadsheet"
DoCmd.OpenForm stDocName, acFormDS, , , , , i

Exit_CommandViewSpreadsheet_Click:
Exit Sub

Err_CommandViewSpreadsheet_Click:
MsgBox Err.Description
Resume Exit_CommandViewSpreadsheet_Click

End Sub
 

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