Mackin, Christopher
CMackin at Quiznos.com
Fri Jun 11 08:41:44 CDT 2004
EXPLICITLY DECLARE YOUR VARIABLES! Dim db as DAO.Database Dim RS as DAO.Recordset Otherwise you are at the whim of how the references are listed and whatever Access finds first as a suitable reference library. -Chris Mackin -----Original Message----- From: Hollis,Virginia [mailto:HollisVJ at pgdp.usec.com] Sent: Friday, June 11, 2004 5:19 AM To: 'accessD at databaseadvisors.com' Subject: [AccessD] Change code to A2003 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 -- _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com