ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   I got this problem run-time error 1004 application defined ... (https://www.excelbanter.com/excel-discussion-misc-queries/98328-i-got-problem-run-time-error-1004-application-defined.html)

Davide Blau

I got this problem run-time error 1004 application defined ...
 
This is my code, when i try to add a xlValidateList in an excel sheet
i receive a run time error
1004 application defined or object defined error ...

I tried also to add other lists or formula inside that sheet, it's
possible i've to add something in my project (mmm ...) ??


Private Sub CommandButton1_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim Foglio1 As Worksheet

Dim PathDataBase As String
Dim list As String

'Store the path of the database
PathDataBase = Sheets("Foglio1").Range("E2").Value

' connect to the Access database
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=" & PathDataBase & ";"

'now find in tblCostruttori and replace in the table
Set rs = New ADODB.Recordset
rs.Open "tblCostruttori", cn, adOpenKeyset, adLockOptimistic,
adCmdTable
lunghezza = rs.RecordCount
lista = ""
Do While (Not rs.EOF)
list = list & rs.Fields("Costruttori") & ";"
rs.MoveNext
Loop
rs.Close
Set rs = Nothing

With Sheets("Foglio1").Range("C2").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop,
Operator:= _
xlBetween, Formula1:=list
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With


mrice

I got this problem run-time error 1004 application defined ...
 

Which line does the macro get stuck on?


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=559840


mrice

I got this problem run-time error 1004 application defined ...
 

Which line does the macro get stuck on?


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=559840



All times are GMT +1. The time now is 10:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com