ADO Recordset won't add, edit, or delete

D

Don Wilson

I am currently developing a Timesheet database in access
2003. I am trying to set a forms record source through the
code window using an ado recordset. I have complete
functionality (add, edit, and delete) as long as the query
is without criteria. I would like to set the criteria to
show records based on a "LoginId". I would also like to
point out that if the criteria is removed, add, edit, and
delete work. But the way you will see below returns
records but does not allow add, edit, or delete.

I hope that all made sense.
Here is the code.


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub Form_Open(Cancel As Integer)

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim intrs As Integer
Dim varLoginId As Integer

DoCmd.SetWarnings False

varLoginId = Forms!frmLogIn!LoginId


'Use the ADO connection that Access uses

'Create an instance of the ADO Recordset class, and
'set its properties
Set rs = New ADODB.Recordset
rs.ActiveConnection = CurrentProject.Connection
rs.Open _
Source:="SELECT tblTimesheets.*,
tblTimesheets.TechID " & _
"FROM tblTimesheets " & _
"WHERE (((tblTimesheets.TechID)= " &
varLoginId & "))", _
CursorType:=adOpenKeyset, _
LockType:=adLockOptimistic


'"WHERE (((tblTimesheets.TechID)=[Forms]![frmLogIn]!
[LoginId]))", _

'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rs
rs.Close
Set rs = Nothing
DoCmd.SetWarnings True

End Sub


Any help would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top