ok i know this is a common freakin question, but i've been at this all day and i can't figure this out. I am including code from a db I wrote. it is the general declaratins and the form load page. When I dedug the error handler kicks in at the line that defines the recordset. I have tried it 2 different ways, and both ways get an error. I know it could be my connection definaition as well, but i can't figure it out These are the 2 ways i tried:
Set rs = New ADODB.Recordset(seen below)
rs.ActiveConection = cn
Option Compare Database
Option Explicit
Dim cn As Connection
Dim rs As New ADODB.Recordset
Dim DelConfirm As Integer
Dim ctl As Control
'sets varibales for connection and recordset, opens connection to table, call fillcontrols procedure that will fill info into textboxes
Private Sub Form_Load()
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.BackColor = vbWhite
End If
Next
cmdInsert.Visible = False
cmdNext.Visible = True
cmdPrev.Visible = True
cmdNew.Visible = True
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
rs.Open "tblEmpInfo", cn, adOpenDynamic, adLockOptimistic, adCmdTable
FillControls
End Sub
Set rs = New ADODB.Recordset(seen below)
rs.ActiveConection = cn
Option Compare Database
Option Explicit
Dim cn As Connection
Dim rs As New ADODB.Recordset
Dim DelConfirm As Integer
Dim ctl As Control
'sets varibales for connection and recordset, opens connection to table, call fillcontrols procedure that will fill info into textboxes
Private Sub Form_Load()
For Each ctl In Controls
If TypeOf ctl Is TextBox Then
ctl.BackColor = vbWhite
End If
Next
cmdInsert.Visible = False
cmdNext.Visible = True
cmdPrev.Visible = True
cmdNew.Visible = True
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
rs.Open "tblEmpInfo", cn, adOpenDynamic, adLockOptimistic, adCmdTable
FillControls
End Sub