VBA On Load User Type Not Defined error

Option Compare Database

Dim RS As ADODB.Recordset

Private Sub Form_Load()
Dim RS As ADODB.Recordset

Set RS = New ADODB.Recordset
RS.Open Me.RecordSource, CurrentProject.Connection, adOpenStatic, adLockOptimistic
If RS.RecordCount = 0 Then
    MsgBox "There are no existing records to edit! Please go to the add form to create some!"
End If

End Sub

I get error messgae user defined type not defined?
Laurie VAsked:
Who is Participating?
1. You have to add reference :
2. I'm not sure about this code. Is need to add?:
Dim CON As ADODB.Connection
Set con = New ADODB.Connection
With con
.ConnectionString = "Provider=YourDB;User ID=UserName;Password=password"
End With
Juan OcasioApplication DeveloperCommented:
You may be missing a reference.
Laurie VAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.