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

Validate Check for dialog box? 1

Status
Not open for further replies.

st3ady

Programmer
Nov 29, 2006
9
0
0
AN
Hey there,

I have a dialog box that has 3 checkboxes, and I need to alter my code so that atleast one checkbox is checked before the user can continue.

here is the code of my dialog box:
Begin Dialog dlgFNR 140, 120, "FNR Attempt Dialog Box"
ButtonGroup .ButtonPressed
OkButton 20, 90, 60, 14

GroupBox 10, 10, 100, 70, "Attempted To Call"
CheckBox 15, 20, 91, 12, "Home Phone", .cbxHome
CheckBox 15, 35, 91, 12, "Alt1 Phone", .cbxAlt1
CheckBox 15, 50, 91, 12, "Alt2 Phone", .cbxAlt2
End Dialog


Dim dlgVar As dlgFNR
nRet = Dialog(dlgVar)

attempt_home = dlgVar.cbxHome
attempt_alt1 = dlgVar.cbxAlt1
attempt_alt2 = dlgVar.cbxAlt2

Any help would be great, thanks :)
 
Code:
Function dlgFNRFunc(identifier$, action, suppvalue)
  dlgFNRFunc = True
  Select Case action
  Case 2
    Select Case identifier$
    Case "BtnOK"
      If dlgValue("cbxHome") = 1 Then dlgFNRFunc = False
      If dlgValue("cbxAlt1") = 1 Then dlgFNRFunc = False
      If dlgValue("cbxAlt2") = 1 Then dlgFNRFunc = False
    End Select
  End Select
End Function

Sub Main
  Begin Dialog dlgFNR 140, 120, "FNR Attempt Dialog Box", .dlgFNRFunc
    ButtonGroup .ButtonPressed
    OkButton 20, 90, 60, 14, .BtnOK
    GroupBox 10, 10, 100, 70, "Attempted To Call"
    CheckBox 15, 20, 91, 12, "Home Phone", .cbxHome
    CheckBox 15, 35, 91, 12, "Alt1 Phone", .cbxAlt1
    CheckBox 15, 50, 91, 12, "Alt2 Phone", .cbxAlt2
  End Dialog

  Dim dlgVar as dlgFNR
  On Error Resume Next
  Dialog dlgVar

  attempt_home = dlgVar.cbxHome
  attempt_alt1 = dlgVar.cbxAlt1
  attempt_alt2 = dlgVar.cbxAlt2
End Sub
 
thanks for your reply Skie! I made the modifications to my code and I will test this out tomorrow morning and let you know how it went. :)
 
Wow, it works great! If the person tries to hit OK without choosing any options, it will do nothing. Excellent!
thanks again ^_^
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top