tree
tree

Reputation: 740

Excel Macro Error - "User Defined Type Not Defined" - References Grayed out

So I created this code (probably don't even have to show it- but just in case!), have not been able to test it as I get "User defined type not defined" on the first line. I saw that I should set the reference in Tools>References but the option is grayed out....

Sub UploadDistributors()
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset

strConn = "Provider=SQLOLEDB-Removed for security-Network Library=DBMSSOCN"

cnn.Open strConn 

Dim k
k = 0

   For i = 1 To 352

   sSQL = "INSERT INTO DistributorsNP (CompanyName, address, city, state, zip, phone,    tollfree) VALUES ("

    'CompanyName
    sSQL = sSQL & Sheet1.Range("B" & i).Value & ","
    'address
    sSQL = sSQL & Sheet1.Range("C" & i).Value & ","
    'city
    sSQL = sSQL & Sheet1.Range("D" & i).Value & ","
    'state
    sSQL = sSQL & Sheet1.Range("E" & i).Value & ","
    'zip
    sSQL = sSQL & Sheet1.Range("F" & i).Value & ","
    'phone
    sSQL = sSQL & Sheet1.Range("G" & i).Value & ","
    'tollfree
    sSQL = sSQL & Sheet1.Range("H" & i).Value & ","



sSQL = sSQL & ")"
rs.Open sSQL, cnn, adOpenStatic, adLockReadOnly, adCmdText

rs.Close

Next

End Sub

Upvotes: 1

Views: 12342

Answers (1)

MattCrum
MattCrum

Reputation: 1110

Guessing you've pressed stop in the editor and are no longer in break mode...?

Upvotes: 2

Related Questions