Report Parameters Problem

fhs

Registered User.
Local time
Today, 23:35
Joined
Aug 8, 2001
Messages
68
Bob Larsen initially helped me with this report and I hope he is available to look at again.

The Director's Report button opens a parameter form requiring a Begin date and an Ending date to query start and end times for employees. This application has run well for the past two months. However, now when the Preview Report button is clicked, a pop-up message: "This expression is typed incorrectly, or it is too complex to be evaluated, etc., etc.

I'm enclosing a copy of the application. If Bob can take a look at this I would really appreciate it. But, if anyone else has a solution I will be deeply appreciative as well.
 

Attachments

The problem is this record - delete it and everything is fine again:

attachment.php
 

Attachments

  • fhs_problemrecord.png
    fhs_problemrecord.png
    14.5 KB · Views: 181
I appreciate you discovering the faulty record. Can I prevent a record like that screwing up the query or is there a way to restrict the user to populating only one field in the frmClock-In Clock-Out?
 
You just need to make sure in the Form's BEFORE UPDATE event that there is a valid value for one or the other time fields. If not, set

Cancel = True
Me.Undo

so that the name isn't stored without a valid entry. Amazingly enough you would think that other record which has the dates but no name would cause a problem but it doesn't because it is the date/time fields which are the things which are sensitive to not having any entry at all. :)
 
Do I place this code in the BEFORE UPDATE event of the form or in each of the fields (Clock_In and Clock-Out)? I tried in the form's event and now I am unable to save the record. Any advice?
 
In the FORM. What is the entire code you have in the form's Before Update event. Like I said, you would need to VALIDATE the entries -

Code:
If Len(Me.Clock_In & vbNullString) = 0 And Len(Me.Clock_Out & vbNullString) = 0 Then
    
    Cancel = True
    If Msgbox("You didn't enter a Clock In or Clock Out time and at least one is required!" & _
              "Do you want to cancel this entry completely?", vbExclamation, "Entry Error!") = vbYes Then
       Me.Undo
   End If
 
Thanks for the code, but it's still not working properly. The pop-up message is displayed despite a double-click in the txtClockInTime or txtClockOutTime. This shouldn't occur. I'm returning the zipped copy. Thanks for your assistance with this mechanism.
 

Attachments

The problem is that you added some stuff to the code (and I had forgotten the ending End If so change this:
Code:
    If Len(Me.txtClockInTime & vbNullString) = 0 And Len(Me.txtClockOutTime & vbNullString) = 0 Then
 
        Cancel = True
 
    End If
 
    If MsgBox("You didn't enter a Clock In or Clock Out time and at least one is required!" & _
              "Do you want to cancel this entry completely?", vbExclamation, "Entry Error!") = vbYes Then
        Me.Undo
 
    End If

to this:
Code:
If Len(Me.txtClockInTime & vbNullString) = 0 And Len(Me.txtClockOutTime & vbNullString) = 0 Then
 
   Cancel = True
 
      If MsgBox("You didn't enter a Clock In or Clock Out time and at least one is required!" & _
"Do you want to cancel this entry completely?", vbExclamation, "Entry Error!") = vbYes Then
         Me.Undo
 
      End If
End If
 

Users who are viewing this thread

Back
Top Bottom