I
I_am_fitz
I want to load a validation drop down box from array values. If I
define this as a string I am limited to 256 characters. If I
reference the first element in the array the drop down box contains
that one name but i want to list them all. I have provided the code
snip with some comments. Thanks.
Dim Stmt As String
Dim Rs As New ADODB.Recordset
Dim RTNDRDLCF As String
Dim RTNUSER(1 To 100) As String
Dim I As Long
Cmd1.ActiveConnection = CON1
Cmd1.CommandType = adCmdText
Stmt = ""
Stmt = Stmt & "SELECT DRDLCF"
Stmt = Stmt & " FROM DATALIB.LTFXX"
Stmt = Stmt & " WHERE CRFD = '09'"
Stmt = Stmt & " AND CRFDT = 'BU'"
Cmd1.CommandText = Stmt
Rs.Open Cmd1
While Not Rs.EOF
RTNDRDL01 = Trim(Rs.Fields("DRDL01").Value)
If RTNDRDL01 <> "" Then
I = I + 1
RTNUSER(I) = Trim(RTNDRDL01)
End If
Rs.MoveNext
Wend
'At this point my RTNUSER() array has 50 names.
Range("C6").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:=RTNUSER 'this does not work, what am I
doing wrong???
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "User Name"
.InputMessage = ""
.ErrorMessage = "Select a Valid Value from List."
.ShowInput = True
.ShowError = True
End With
define this as a string I am limited to 256 characters. If I
reference the first element in the array the drop down box contains
that one name but i want to list them all. I have provided the code
snip with some comments. Thanks.
Dim Stmt As String
Dim Rs As New ADODB.Recordset
Dim RTNDRDLCF As String
Dim RTNUSER(1 To 100) As String
Dim I As Long
Cmd1.ActiveConnection = CON1
Cmd1.CommandType = adCmdText
Stmt = ""
Stmt = Stmt & "SELECT DRDLCF"
Stmt = Stmt & " FROM DATALIB.LTFXX"
Stmt = Stmt & " WHERE CRFD = '09'"
Stmt = Stmt & " AND CRFDT = 'BU'"
Cmd1.CommandText = Stmt
Rs.Open Cmd1
While Not Rs.EOF
RTNDRDL01 = Trim(Rs.Fields("DRDL01").Value)
If RTNDRDL01 <> "" Then
I = I + 1
RTNUSER(I) = Trim(RTNDRDL01)
End If
Rs.MoveNext
Wend
'At this point my RTNUSER() array has 50 names.
Range("C6").Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:=RTNUSER 'this does not work, what am I
doing wrong???
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = "User Name"
.InputMessage = ""
.ErrorMessage = "Select a Valid Value from List."
.ShowInput = True
.ShowError = True
End With