Table update problem

echo0001

Registered User.
Local time
Today, 13:57
Joined
Aug 30, 2008
Messages
55
Hello,

I am having a spot of trouble.

I have a check in and out system, when a person is checked in a new record is created on a table with the Now() data and the persons name, when they check out i want the Now() data to update on the last record made for that person.

the problem i am having is when i check out a person whom is already on the table a few times the Now() data replaces all the check out data, giving in correct times.

I have included screenshots and sample code, any help would be great.

Code:
Dim mySQL1 As String
    
If DMax("[Check Out]", "Check In/Out") >= DateAdd("n", -1, Now) Then

MsgBox "You cannot Check Out again within 1 Minute"

Else
    
    mySQL1 = " UPDATE [Check In/Out]"
    mySQL1 = mySQL1 & " SET [Check In/Out].[Check Out] = Now() "
    mySQL1 = mySQL1 & " WHERE ((([Check In/Out].[Check Out])=IsEmpty([Check In/Out]![Check Out])) AND (([Check In/Out].[Childs Name])=[Forms]![Check In/Out Form]![Combo19]));"
    
Debug.Print mySQL1
DoCmd.SetWarnings False
DoCmd.RunSQL mySQL1
DoCmd.SetWarnings True

End If

In fact now since i have changed the code to the above the table is not updating at all with the new Now() data.
 

Attachments

  • db1.PNG
    db1.PNG
    8.5 KB · Views: 74
From Access help on IsEmpty:

IsEmpty returns True if the variable is uninitialized, or is explicitly set to Empty; otherwise, it returns False.False is always returned if expression contains more than one variable. IsEmpty only returns meaningful information for variants.

I think you used the wrong function to check for "empty" variable/field in table.

Try and use IsNull instead.

Code:
mySQL1 = mySQL1 & " WHERE ((([Check In/Out].[Check Out])=[B]IsNull[/B]([Check In/Out]![Check Out])) ......


also using a fieldname Check In/Out is not a good idea. Use CheckInOut instead.
JR
 
Ok will try it late after work, thank you for the quick reply
 

Users who are viewing this thread

Back
Top Bottom