How to Pass Option Group values in OpenArg

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 if
they want to see it in 3 ways-

Last name, First name, date Received
Date Received, Last name, First name
Date completed, Last name, First name

I did an options group with these 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


+++++
My current Opening button-
+++++


Private Sub Command53_Click()

End Sub
Private Sub CommandSpreadsheetOpen_Click()
On Error GoTo Err_CommandSpreadsheetOpen_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Personnel2009Spreadsheet"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CommandSpreadsheetOpen_Click:
Exit Sub

Err_CommandSpreadsheetOpen_Click:
MsgBox Err.Description
Resume Exit_CommandSpreadsheetOpen_Click

End Sub
 
K

KARL DEWEY

If I understand you correctly you desire the fields left to right to change
based on the option selected.
You could have options group controling nested IIF in a query to feed the
form. Like this --
Left_Display: IIF([Forms]![YourForm]![Frame4] = 1, [Last name],
IIF([Forms]![YourForm]![Frame4] = 2, [Date Received],
IIF([Forms]![YourForm]![Frame4] = 3, [Date Completed], "Error")))

Middle_Display: IIF([Forms]![YourForm]![Frame4] = 1, [First name],
IIF([Forms]![YourForm]![Frame4] = 2, [Last name],
IIF([Forms]![YourForm]![Frame4] = 3, [Last name], "Error")))

Right_Display: IIF([Forms]![YourForm]![Frame4] = 1, [Date Received],
IIF([Forms]![YourForm]![Frame4] = 2, [First name],
IIF([Forms]![YourForm]![Frame4] = 3, [First name], "Error")))
 
D

Damon Heron

Your line
DoCmd.OpenForm stDocName, , , stLinkCriteria
has no value for stLinkCriteria, so it wouldn't do anything anyway.
Try:
DoCmd.OpenForm stDocName, , , , , ,[your option frame value]
As an example,
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
 
D

dohernan

Thanks, but I already have an Options group of 3, how do I 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." ?
 
K

KARL DEWEY

I do not know how to use the OpenArgs argument of the OpenForm method so I
posted how to pass to query to feed the second form.
 
D

dohernan

Thanks everyone, 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