record count problem.

ansentry

Access amateur
Local time
Tomorrow, 09:08
Joined
Jun 1, 2003
Messages
995
I am using access 97

Can anyone see what may be wrong with this code, sometimes it works and other time not.

If the record count is greater that 2 the header will say Vehicle NOT Returned, then if switch to design view and then back it will say Vehicles Not Returned (which is correct).

This is not very important in however it has got me beaten.

The reason for HeaderA_Label and HeaderB_Label is so that the text has a shadow effect.

I someone can offer advise then I would be grateful.


Private Sub Form_Open(Cancel As Integer)


If Me.RecordsetClone.RecordCount >= 2 Then



Me.HeaderA_Label.Caption = "Vehicles NOT Returned"
Me.HeaderB_Label.Caption = "Vehicles NOT Returned"
Me.Caption = "Vehicles Not Returned"

Else


Me.HeaderA_Label.Caption = "Vehicle NOT Returned"
Me.HeaderB_Label.Caption = "Vehicle NOT Returned"
Me.Caption = "Vehicle Not Returned"

End If
End Sub
 
Put it in the Form_Load and see if the results are the same.
 
Thank you for your reply.

Yes I have tried Form_Loan , Form_Open and Form_Current all with the same result.
 
Copy and past this code:


Code:
Private Sub Form_Load() 

    Dim x As Integer, rs As DAO.RecordSet

    Set rs = Me.RecordsetClone
    rs.MoveLast
    x = rs.RecordCount

    Me.HeaderA_Label.Caption = IIf(x>=2, "Vehicles NOT Returned", "Vehicle NOT Returned")
    Me.HeaderB_Label.Caption = IIF(x>=2, "Vehicles NOT Returned", "Vehicle NOT Returned")
    Me.Caption = IIf(x>=2, "Vehicles Not Returned", "Vehicle Not Returned")

    Set rs = Nothing

End Sub
 
Record Count Problem

Mile-O-Phile

Thank you very much, it is working.


Regards,




:)
 

Users who are viewing this thread

Back
Top Bottom