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!"
DoCmd.Close
End If
RS.Close

End Sub

I get error messgae user defined type not defined?
Laurie VAsked:
Who is Participating?
 
OddyWriterMr.Commented:
1. You have to add reference :
img1.png
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"
.Open
End With
0
 
Juan OcasioApplication DeveloperCommented:
You may be missing a reference.
0
 
Laurie VAuthor Commented:
Thanks!!!
0
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.