+ Reply to Thread
Results 1 to 3 of 3

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

  1. #1
    Davide Blau
    Guest

    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


  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    Which line does the macro get stuck on?
    Martin

  3. #3
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Response

    Which line does the macro get stuck on?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1