Between in IF statement

echo0001

Registered User.
Local time
Today, 13:52
Joined
Aug 30, 2008
Messages
55
hello,

Just need a second pair of eyes on this.

Code:
If Tables![Check In/Out].[Check In] = "Between Time() and (Time()-Minute(5))" Then

Not working, error 424, object required

Cheers
 
1. You can't use Tables![Check In/Out] for anything. You can't use something like that with Tables!. It just isn't possible.

2. Not sure what you are trying to get here. Are you trying to limit some query or something to the data that includes only times within 5 minutes of the current time?
 
1. You can't use Tables![Check In/Out] for anything. You can't use something like that with Tables!. It just isn't possible.

2. Not sure what you are trying to get here. Are you trying to limit some query or something to the data that includes only times within 5 minutes of the current time?

The following code might clear up what im trying to do.

Code:
Private Sub Command14_Click()

Dim mySQL0 As String

If Tables![Check In/Out].[Check In] = "Between Time() and (Time()-Minute(5))" Then

MsgBox test

    Else
    
    mySQL0 = " INSERT INTO [Check In/Out] ([Childs Name], [Check In], [Date01]) "
    mySQL0 = mySQL0 & " SELECT '" & Me![Combo12] & "' AS [Childs Name], Time() AS [Check In], Date() AS [Date01] "
    
Debug.Print mySQL0
DoCmd.SetWarnings False
DoCmd.RunSQL mySQL0
DoCmd.SetWarnings True

End If

End Sub

Basically i dont want the "check in" botton to add a new record if one has already been created within 5 mins. as it is easy to click i button twice.
 
FYI - that is button, not botton.

Also, I HOPE that your field Check In is a DATE and Time field.

Code:
If DMax("[Check In]", "Check In/Out") Between DateAdd("n", -5, Now) And Now Then
 
FYI - that is button, not botton.

Also, I HOPE that your field Check In is a DATE and Time field.

Code:
If DMax("[Check In]", "Check In/Out") Between DateAdd("n", -5, Now) And Now Then

Getting a compile error on the "Between" part of the If Statement.
 
Okay, try this instead:

Code:
If DMax("[Check In]", "Check In/Out") >= DateAdd("n", -5, Now) Then
 
the code is running now, but the task of not letting it create another record isnt working, i have tried to change the >= to work but with no luck
 
Put a breakpoint on the code at the start of the IF statement and see what happens when you F8 through. If you have a record input within 5 minutes, it should branch there, but it all depends on what you are storing in that field. Is it a date and time?
 
sorry about that had to take the input mask out and it worked
 

Users who are viewing this thread

Back
Top Bottom