Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Problems with cascading combo box, appears to only be 1 column's numeric values (zipcodes)

I've gone over this countless times trying to debug, modify, test..
and searched for answers on the NGs.

The combobox (exists on a UserForm) that's causing all the trouble
is to be filled/updated with numeric data (ZipCodes) where as all the
other ones are filled with text strings (City,State,Etc). I found this
code
on a French language XL forum and have tried to adapt it to my case.

Dim'd Item As Variant?

-------------------------------------------------------------------------------------------------
Private Sub cboLimitEstadoDes_Change()
Dim i As Integer
Dim ColBase1 As New Collection
Dim Item As Variant
Dim X As Byte

For X = 1 To 4
Me.Controls("ComboBox" & X).Style = fmStyleDropDownList
Next

' The following is a workaround to combobox update latencyBS
If cboLimitEstadoDes.Value = "A - H" Then
' Pulls values from worksheet LocMX
With LocMX
Lista = .Range("A1:D" & .Range("A32767").End(xlUp).Row)
End With

ElseIf cboLimitEstadoDes.Value = "J - Q" Then
' Pulls values from worksheet LocMX2
With LocMX2
Lista = .Range("A1:D" & .Range("A32767").End(xlUp).Row)
End With

ElseIf cboLimitEstadoDes.Value = "S - Z" Then
' Pulls values from worksheet LocMX2
With LocMX3
Lista = .Range("A1:D" & .Range("A32767").End(xlUp).Row)
End With

' Else 'could put msgbox w/response later...
End If

On Error Resume Next
For i = 1 To UBound(Lista)
ColBase1.Add Lista(i, 1), Lista(i, 1)
Next
On Error GoTo 0

For Each Item In ColBase1
Me.ComboBox1.AddItem Item
Next
End Sub
-----------------------------------------------------------------
Private Sub ComboBox1_Change()
ComboUpdates 2
End Sub
-----------------------------------------------------------------
Private Sub ComboBox2_Change()
ComboUpdates 3
End Sub
-----------------------------------------------------------------
Private Sub ComboBox3_Change()
ComboUpdates 4
End Sub
-----------------------------------------------------------------
Private Sub ComboUpdates(Num As Byte)
Dim i As Integer
Dim ColBaseX As New Collection
Dim Item As Variant
Dim X As Byte

For X = Num To 4
Me.Controls("ComboBox" & X).Clear
Next

On Error Resume Next
For i = 1 To UBound(Lista)
If Lista(i, Num - 1) = Me.Controls("ComboBox" & Num - 1) Then
ColBaseX.Add Lista(i, Num), Lista(i, Num)
End If
Next
On Error GoTo 0

For Each Item In ColBaseX
Me.Controls("ComboBox" & Num).AddItem Item
Next
End Sub
---------------------------------------------------------------------------------------------------
Private Sub UserForm_Initialize()
txtNombreDes.Value = ""
txtApellidoDes.Value = ""
With cboTituloDes
.AddItem "Señor"
.AddItem "Señora"
End With
cboTituloDes.Value = ""
txtClaveTUDes.Value = ""
txtTelCelDes.Value = ""
txtTelCasaDes.Value = ""
txtDomicilio1Des.Value = ""
txtDomicilio2Des.Value = ""
With cboLimitEstadoDes
.AddItem "A - H"
.AddItem "J - Q"
.AddItem "S - Z"
End With
cboLimitEstadoDes.Value = ""
ComboBox1.Value = ""
ComboBox2.Value = ""
ComboBox3.Value = ""
ComboBox4.Value = ""
optIndividualDes = True
txtInformacionDes.Value = ""
cboTituloDes.SetFocus
End Sub
---------------------------------------------------------------------------------------------------

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Problems with cascading combo box, appears to only be 1 column's n

Robert,
I have a solution that I could send you if you wish -- it is too complicated
to easily explain.
I haven't found a way to post a file to this forum so I would need
and email or other method of sending it to you.

OR
you can post your question on
Woody's lounge
http://www.wopr.com/cgi-bin/w3t/post...?Cat=&Board=xl
and I could post it there.


"tHeRoBeRtMiTcHeLL" wrote:

I've gone over this countless times trying to debug, modify, test..
and searched for answers on the NGs.

The combobox (exists on a UserForm) that's causing all the trouble
is to be filled/updated with numeric data (ZipCodes) where as all the
other ones are filled with text strings (City,State,Etc). I found this
code
on a French language XL forum and have tried to adapt it to my case.

Dim'd Item As Variant?

-------------------------------------------------------------------------------------------------
Private Sub cboLimitEstadoDes_Change()
Dim i As Integer
Dim ColBase1 As New Collection
Dim Item As Variant
Dim X As Byte

For X = 1 To 4
Me.Controls("ComboBox" & X).Style = fmStyleDropDownList
Next

' The following is a workaround to combobox update latencyBS
If cboLimitEstadoDes.Value = "A - H" Then
' Pulls values from worksheet LocMX
With LocMX
Lista = .Range("A1:D" & .Range("A32767").End(xlUp).Row)
End With

ElseIf cboLimitEstadoDes.Value = "J - Q" Then
' Pulls values from worksheet LocMX2
With LocMX2
Lista = .Range("A1:D" & .Range("A32767").End(xlUp).Row)
End With

ElseIf cboLimitEstadoDes.Value = "S - Z" Then
' Pulls values from worksheet LocMX2
With LocMX3
Lista = .Range("A1:D" & .Range("A32767").End(xlUp).Row)
End With

' Else 'could put msgbox w/response later...
End If

On Error Resume Next
For i = 1 To UBound(Lista)
ColBase1.Add Lista(i, 1), Lista(i, 1)
Next
On Error GoTo 0

For Each Item In ColBase1
Me.ComboBox1.AddItem Item
Next
End Sub
-----------------------------------------------------------------
Private Sub ComboBox1_Change()
ComboUpdates 2
End Sub
-----------------------------------------------------------------
Private Sub ComboBox2_Change()
ComboUpdates 3
End Sub
-----------------------------------------------------------------
Private Sub ComboBox3_Change()
ComboUpdates 4
End Sub
-----------------------------------------------------------------
Private Sub ComboUpdates(Num As Byte)
Dim i As Integer
Dim ColBaseX As New Collection
Dim Item As Variant
Dim X As Byte

For X = Num To 4
Me.Controls("ComboBox" & X).Clear
Next

On Error Resume Next
For i = 1 To UBound(Lista)
If Lista(i, Num - 1) = Me.Controls("ComboBox" & Num - 1) Then
ColBaseX.Add Lista(i, Num), Lista(i, Num)
End If
Next
On Error GoTo 0

For Each Item In ColBaseX
Me.Controls("ComboBox" & Num).AddItem Item
Next
End Sub
---------------------------------------------------------------------------------------------------
Private Sub UserForm_Initialize()
txtNombreDes.Value = ""
txtApellidoDes.Value = ""
With cboTituloDes
.AddItem "Señor"
.AddItem "Señora"
End With
cboTituloDes.Value = ""
txtClaveTUDes.Value = ""
txtTelCelDes.Value = ""
txtTelCasaDes.Value = ""
txtDomicilio1Des.Value = ""
txtDomicilio2Des.Value = ""
With cboLimitEstadoDes
.AddItem "A - H"
.AddItem "J - Q"
.AddItem "S - Z"
End With
cboLimitEstadoDes.Value = ""
ComboBox1.Value = ""
ComboBox2.Value = ""
ComboBox3.Value = ""
ComboBox4.Value = ""
optIndividualDes = True
txtInformacionDes.Value = ""
cboTituloDes.SetFocus
End Sub
---------------------------------------------------------------------------------------------------


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If statement for alpha numeric combo AND numeric only Jdude Excel Discussion (Misc queries) 4 July 13th 09 06:14 AM
Clean-Up Cascading Data Validation List Values Lisa C. Excel Discussion (Misc queries) 4 March 30th 09 01:02 PM
Cascading combo boxes for project Hustler24 New Users to Excel 9 March 18th 06 06:22 AM
cascading combo boxes dan Excel Programming 1 May 13th 04 09:00 PM
how to use combo cascading box Paulo A. Carvalho Excel Programming 0 September 21st 03 03:01 AM


All times are GMT +1. The time now is 07:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"