Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Groups on Unbound Form

Status
Not open for further replies.

Melagan

MIS
Nov 24, 2004
443
US
Greetings,

I'm working with an unbound form and two option groups. The first option group, optReport, has two option buttons, stored values are 1 or 2. The second option group, optSend, has three options, stored values are 1, 2, and 3.
The default value for optReport and optSend is 1.


Finally, there is a command button to execute the following code:
Code:
Private Sub cmdOK_Click()
Dim strReport As String
    
    Select Case optReport
        Case 1
            strReport = "rptOptionA"
        Case 2
            strReport = "rptOptionB"
        Case Else
            Debug.Print "Please choose a report."
    End Select

    If optSend = 1 Then
        DoCmd.OpenReport strReport, acViewPreview
            
        ElseIf optSend = 2 Then
            DoCmd.OpenReport strReport, acViewNormal
            
'I havn't written the sendobject.email procedure yet.
            ElseIf optSend = 3 Then
                MsgBox "Email Procedure to follow", vbOKOnly, "Email"
    End If
    
End Sub

All I want to do is ask the user which report they want to send, Option A or B, and how they want it done (Preview, normal, or email)
It works perfectly until I choose Option B (where optReport should = 2). When I do, it still acts as if optReport = 1 and pulls rptOptionA. Any ideas?

(This is my first time working with SELECT CASE clauses so I'm sure the mistake(s) is/are in there. Thank you in advance!


~Melagan
______
"It's never too late to become what you might have been.
 
You must capture the option frame value to use it in a Select Case

Select Case optReport.value

Why not use a Select Case for OptSend?




Hope this helps...........
 
Just as a check, in design view, are the Option Value's for each radio button correct?
 
To follow up on Lewds, the following has been working for years. I've never done .value for an option frame.
Select Case [RptFrame]
Case 1
WClause = "[DateOfLease] Between #" & _
Me![Start] & "# AND #" & _
Me![End] & "#"
RName = "Sales_And_Leasing_Rpt"
Case 2
WClause = "[FinalSettlementDate]is null"
RName = "Sales_Pending_Report"
End Select
 
I have verified that the option values for each radio button are indeed correct. I tried using the Select Case optReport.Value method and it still does not open rptOptionB even if the optReport's value is 2. I have even manually set optReport's value to 2 in datasheet view and still nada.




~Melagan
______
"It's never too late to become what you might have been.
 
looooooooooooooool haha oh my... I found the error.

rptOptionA and rptOptionB are identical in layout - they just have different record sources, so the reports look very similar. The problem was that both reports had the same caption, so when rptOptionB opened up with the caption from rptOptionA (I forgot to change the caption for rptOptionB), I assumed that it WAS rptOptionA.

Incidently, to make this thread at least somewhat productive -- select case optReport.value works as well as without.

Thank you both for the quick responses though, much appreciated!


~Melagan
______
"It's never too late to become what you might have been.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top