Full Version: Error Message
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
SCOTTEADIE
Hi
can any one help with this code, when i try and run it i get an error message

Compile Error - Method or data member not found

i have "borrowed" this code from Northwind sample database to autofill in check boxes
and i cannot get it to work - it keeps coming up with the error on line - rs.Edit
why is this??

thanks for any help

The Code Is:

CODE
Private Sub Form_Close()
    ' clear all checkboxes
    
    Dim db As Database
    Dim rs As Recordset
    
On Error GoTo HandleErr

    Set db = CurrentDb
    Set rs = db.OpenRecordset("select PrintFlag from tblContacts", _
      dbOpenDynaset)
    If rs.RecordCount > 0 Then
        Do Until rs.EOF
        rs.Edit
                rs!PrintFlag = False
            rs.Update
            rs.MoveNext
        Loop
        Me!PrintLabelsSub!ckSelect = False
        Me!PrintLabelsSub!lblSelect.Caption = "Select All tblContacts"
    End If
MicroE
Make sure to add the Microsoft DAO library to your references.

Also change you DIM statements to:
Dim db As DAO.Database
Dim rs As DAO.Recordset
dannyseager
Also I think that if you have DAO and ADO checked the DAO will need to be above ADO... but that might only be if you've not declared your recordset type as suggested by Matt.
SCOTTEADIE
Thank You Danny & Matt

thanks guys
works a treat now

Best regards
Scott
dannyseager
glad to help
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.