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!

Dialog box variable problem

Status
Not open for further replies.

Person51

Programmer
Mar 3, 2006
16
0
0
US
Hello again -
Having a problem with a dialog box, I have 3 DropListBoxes, each have at least 3 options to choose from in each one. Also, there is a CheckBox to which if the checkbox is used, a textbox comes available. I've used the DlgVisible and DlgEnable functions, and could get it all to semi-work, however, certain selections from the ListBoxes would turn the Enable / Visible on and off at when selections were made.
Here's some code :
Declare Function FileDlgFunction(identifier$, action, suppvalue) 'grabbed from the help files

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


Begin Dialog Macroname 84, 31, 412, 177, "Header Here" + ORDTN, .FileDlgFunction
Text 10, 7, 47, 8, "Install Date", .DueDate
TextBox 5, 20, 41, 14, .InstallDate
Text 6, 36, 40, 20, "(MM-DD-YY)"
Text 124, 7, 47, 8, "Order Number", .Ord_PON
TextBox 92, 20, 84, 14, .PON
Text 231, 8, 47, 8, "L-T ", .Listing
DropListBox 204, 22, 95, 44, "Option 1"+chr$(9)+"Option 2"+chr$(9)+"Option 3", .DropListBox1
Text 7, 55, 47, 8, "First Name", .FirstName
TextBox 2, 67, 50, 14, .F_Name
Text 62, 55, 47, 8, "Last Name", .LastName
TextBox 53, 67, 50, 14, .L_Name
Text 125, 55, 47, 8, "HSN", .ST_Num
TextBox 117, 67, 36, 14, .S_Number
Text 166, 55, 47, 8, "Dir.", .Direction
TextBox 159, 67, 24, 14, .Dir_Type
Text 216, 55, 47, 8, "Street Name", .ST_Name
TextBox 194, 67, 81, 14, .S_Name
Text 279, 55, 47, 8, "St. Type", .ST_Type
TextBox 278, 67, 31, 14, .S_Type
Text 6, 103, 47, 8, "Unit", .Add_Loc
TextBox 3, 117, 24, 14, .Unit
Text 46, 103, 47, 8, "Floor", .Add_Loc2
TextBox 43, 117, 24, 14, .Unit2
Text 86, 103, 47, 8, "Bldg", .Add_Loc3
TextBox 83, 117, 24, 14, .Unit3
Text 164, 103, 47, 8, "City", .Customer_City
TextBox 118, 116, 102, 14, .City
Text 232, 103, 22, 8, "Zip", .Customer_Zip
TextBox 224, 116, 31, 14, .Zip
CheckBox 269, 100, 41, 14, "Comm", .CheckBox
TextBox 268, 116, 34, 14, .Comm
Text 29, 142, 55, 8, "Inbound Blocking", .InboundBlk
DropListBox 5, 153, 128, 64, "Option 1"+chr$(9)+"Option 2"+chr$(9)+"Option 3"+chr$(9)+"Option 4", .DropListBox2
Text 200, 142, 61, 8, "Outbound Blocking", .OutboundBlk
DropListBox 164, 153, 143, 64, "Option 1"+chr$(9)+"Option 2"+chr$(9)+"Option 3"+chr$(9)+"Option 4"+chr$(9)+"Option 5", .DropListBox3
OkButton 336, 110, 50, 20
CancelButton 336, 142, 50, 20
Picture 320, 11, 84, 80, "C:\Path here", 0
GroupBox 0, 0, 312, 50, ""
GroupBox 0, 48, 110, 50, ""
GroupBox 112, 48, 200, 50, ""
GroupBox 0, 96, 110, 40, ""
GroupBox 112, 96, 147, 40, ""
GroupBox 0, 134, 312, 36, ""
GroupBox 314, 0, 96, 98, ""
GroupBox 314, 96, 96, 75, ""
GroupBox 262, 96, 50, 40, ""
End Dialog

Dim Source as Macroname
On Error Resume Next
Dialog Source
If Err = 102 Then
STOP
End If

Check = Source.CheckBox
Comm_Field = Source.Comm

End Sub
Function FileDlgFunction(identifier$, action, suppvalue)
Select Case action
Case 1
DlgVisible(Check)
DlgVisible(Comm_Field),0
Case 2
If DlgControlID(Check)=0 Then
If DlgContolID(Check)<>1 Then
DlgVisible "Check",1
DlgVisilbe "Comm_Field",1
End If
End If
End Select
End Function

I believe that that the ID being equal to the same positons as Option1&2 in the DropList makes it impossible to get a valid check. Any help would be welcomed.
- 51
 
Code:
Function FileDlgFunc(identifier$, action, suppvalue)
  Select Case action
  Case 1
    DlgVisible("CheckBox"),1
    DlgVisible("Comm"),0
  Case 2
    Select Case identifier$
    Case "CheckBox"
      If DlgValue("CheckBox") = 1 Then
          DlgVisible "Comm",1
      Else
          DlgVisible "Comm",0
      End If
    End Select
End Function
If you're using an identifier (like .Comm), then you request the identifier instead of a number or using source.identifier. The identifiers are case sensative, so "Comm" works but "comm" would give you an error.
 
you'll need to make the following changes

Function FileDlgFunction(identifier$, action, suppvalue)
Select Case action
Case 1
DlgVisible("CheckBox"),1
DlgVisible("Comm"),0
Case 2
Select Case identifier$
Case "CheckBox"
If DlgValue("CheckBox") = 1 Then
DlgVisible "Comm",1
Else
DlgVisible "Comm",0
End If
End Select
End Select
End Function

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top