[AccessD] Change code to A2003

Hollis,Virginia HollisVJ at pgdp.usec.com
Fri Jun 11 06:19:07 CDT 2004


I have been using the below code to count the number of hits on a form. I
installed A2003 yesterday & receive an error on RS.Edit. In A2K I added a
reference to DAO 3.6 & the code would work. But in 2003 this is not listed
in the references.

 

What can I change the code to so it will work correctly?

 

Virginia

 

********************

 

Public Function CountThisForm(frm As Form) As Boolean

Dim db As Database

Dim RS As Recordset

Dim SQL As String

Set db = CurrentDb

SQL = "Select * FROM tblCounter Where FormName = """ & frm.Name & """;"

Set RS = db.OpenRecordset(SQL, dbOpenDynaset)

If RS.RecordCount > 0 Then

    RS.Edit

    RS!HitCount = RS!HitCount + 1

    RS.Update

Else

    RS.AddNew

    RS!FormName = frm.Name

    RS!HitCount = 1

End If

RS.Close

Set RS = Nothing

End Function




More information about the AccessD mailing list