Count Number of Records in table

ewong1

Eric Wong
Local time
Today, 05:06
Joined
Dec 4, 2004
Messages
96
I have the code below - what I am trying to accomplish is determine whether or not there are any records in "tblEquipmentSchedule" that have a matching date and schedule type as the forms current view. I know for a fact that there are some records that exist - for example if I put in the date 5/21/06 for schedule type "1" I should get a response later in my code that there is 1 record in teh database. This is not happening though. Any ideas on how I can fix this?

Code:
    Dim db As DAO.Database
    Set db = CurrentDb
    
    Dim strSQL As String
    strSQL = "tblEquipmentSchedule"
    
    Dim rs As DAO.Recordset
    Set rs = db.OpenRecordset(strSQL, dbOpenTable)
    
    Dim intRecordCount As Integer

    'Determine if Schedule has already been created for the date provided in "dtmSchedule" field and "idScheduleType"
    intRecordCount = 0
    
    Do Until rs.EOF Or intRecordCount = 1
        
        If (rs!dtmSchedule = Me.dtmSchedule) And (rs!idScheduleType = Me.cboScheduleType) Then
            intRecordCount = intRecordCount + 1
        Else
        End If
        rs.MoveNext
    Loop
    
    rs.Close
    db.Close
 
ewong,

intHowMany = DCount("[ScheduleType]", "tblEquipmentSchedule", "[ScheduleType] = '" & Me.cboScheduleType & "'")

Wayne
 

Users who are viewing this thread

Back
Top Bottom