Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Populating a Validation List with SQL

I keep getting an error (Automation Error. The object invoked has disconnected from its clients.) when I'm using a variable with a lot of data to populate my validation list box using SQL. However, if I hardcode in the same values instead of using a variable then it works fine. I would like to supply this information dynamically from a database so the data is updated without user intervention. Any ideas? Here is the code I'm using

Sub Build_Dropdown_List(ByVal strWrkSheet As String, ByVal strRange As String, ByVal strValues As String
Dim strQuote As Strin
On Err GoTo errHandle

strQuote = """
With Worksheets(strWrkSheet).Range(strRange).Validatio
.Delet
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=
xlBetween, Formula1:=strValues <--------------"THIS IS THE PLACE WHERE THE PROBLEM OCCURS"---------------
.IgnoreBlank = Tru
.InCellDropdown = Tru
.InputTitle = "
.ErrorTitle = "
.InputMessage = "
.ErrorMessage = "
.ShowInput = Tru
.ShowError = Tru
End Wit
End Su

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Populating a Validation List with SQL

Rone

I don't know this for a fact, but I'll be there's a limit to what you can
pass to Formula1. And I'll be it's 255 characters, but I haven't tested it.
Try this

Operator:= _ xlBetween, Formula1:=Left(strValues,254)

If that works, keep going up and see when it breaks.

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com


Rone wrote:
I keep getting an error (Automation Error. The object invoked has
disconnected from its clients.) when I'm using a variable with a lot of
data to populate my validation list box using SQL. However, if I
hardcode in the same values instead of using a variable then it works
fine. I would like to supply this information dynamically from a
database so the data is updated without user intervention. Any ideas?
Here is the code I'm using:

Sub Build_Dropdown_List(ByVal strWrkSheet As String, ByVal strRange As
String, ByVal strValues As String) Dim strQuote As String
On Err GoTo errHandler

strQuote = """"
With Worksheets(strWrkSheet).Range(strRange).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _ xlBetween, Formula1:=strValues
<--------------"THIS IS THE PLACE WHERE THE PROBLEM
OCCURS"---------------- .IgnoreBlank = True .InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
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
Populating a data validation list based on criteria Ciarán Excel Discussion (Misc queries) 3 February 27th 09 08:03 AM
Validation list populating multiple cells Jason Excel Discussion (Misc queries) 4 February 5th 09 06:25 PM
drop down list populating Pammy Excel Discussion (Misc queries) 2 October 27th 08 04:25 PM
.AddItem list and populating combobox with created list pallaver Excel Discussion (Misc queries) 8 June 27th 08 12:36 PM
Populating a Data Validation List Jim Skrydlak Excel Discussion (Misc queries) 2 September 7th 07 12:00 AM


All times are GMT +1. The time now is 05:06 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"