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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtaining Results From Impromptu Checkboxes

Status
Not open for further replies.

ljh2

Technical User
Jun 27, 2005
2
US
Please help a Novice....I have a very simple Impromptu Macro with dialog box that has only two checkboxes. My question is: how do I know (and use) the value of the boxes that are checked (ie...checkbox1 and 2)?

Here's the dialog:

Begin Dialog colltypeDialog 251, 84, "Select Type of Report"
GroupBox 5, 4, 135, 60, "Select:"
OptionGroup .OptionGroup3
CheckBox 10,20,112,14, "Summary Management Reports ",.CheckBox1
CheckBox 10,40,112,14, "Detailed Reports",.CheckBox2
OkButton 170, 6, 54, 14
CancelButton 170, 22, 54, 14
End Dialog

Dim mydialog as colltypeDialog
On Error Resume Next
Dialog mydialog

Any help would be appreciated. Thanks!
 
You need to check for mouse actions i.e.

Code:
Declare Function FileDlgFunction(identifier$, action, suppvalue)
Dim ReturnValue$

Sub Main()
   Dim identifier$
   Dim action as Integer
   Dim suppvalue as Integer

Begin Dialog collTypeDialog 251, 84, "Select Type of Report",.FileDlgFunction

      GroupBox  5, 4, 135, 60, "Select:"
      OptionGroup .OptionGroup3
         CheckBox 10,20,112,14, "Summary Management Reports ",.CheckBox1
         CheckBox 10,40,112,14, "Detailed Reports",.CheckBox2
         OkButton  170, 6, 54, 14
         CancelButton  170, 22, 54, 14
   End Dialog
  
   Dim mydialog as collTypedialog
    On Error Resume Next
   Dialog mydialog
      
   msgbox ReturnValue
End Sub

Function FileDlgFunction(identifier$, action, suppvalue)
   Select Case action
      Case 1 
      Case 2   'user changed control or clicked a button
         If DlgControlID(identifier$)=2 then
            If DlgValue(2)=1 then
               ReturnValue = "summary"
            End If
         ElseIf DlgControlID(identifier$)=3 then
            If DlgValue(3)=1 then
               ReturnValue = "detail"
            End If    
         End If
   End Select

End Function

The basic logic is there.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Thank you very much! This helps.
 
A small on clarification on Gary's useful tip. You do not have to use the dialog function in order to read the result of the checkbox action in the body of the macro. You do need the dialog function to change the behavior of the general dialog calling it before the user checks 'OK'.

Dave G.


The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data"
[pc2]
Want good answers? Read FAQ401-2487 first!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top