E
Evi
together.Opal" <[email protected]> wrote in message news:15c02213-1dce-45de-Something strange....when I use Dlookup....I have tried several in a
txt box
it comes up blank. I just tried, as you suggested Evi:=DLookUp("[ShiftName]","ShiftName","TimeValue([StartofShift])<= #" &
TimeValue(Now()) & "# AND TimeValue([EndofShift]) >= #" &
TimeValue(Now()) & "#")and the box is blank.When I tried the echo false and my main form disappeared and I could
not retrieve it. I had to close
out the database and re-open even if I commented out the lines of
code.On what event did you put the Me.txtShiftName.Requery?Hi Opal
Echo False must be followed by Echo True or it stays switched off.
This code is put in the On Timer Event.Comment out the On Timer Event for now, until you get the text box working.
It works without the On Timer, it just doesn't update.In the DLookup, remember to replace my field and table/Query names with
yours.I see you've got ShiftName as the query or table name which the DLookup is
reading from. Is that what you have called your query or table which holds
the shift times?The Syntax for DLookUp isDLookup("[TheFieldinThe OtherTableOrQueryWhich you want to find]", "The
Table Or Query which has that field", "Any Criteria needed for finding that
field")Make sure that the DLookup is all on one line (the email will almost
certainly break it up).I've found for the StartOfShift and EndOFShift, it works best if you format
them *in your table* as
You can use a different format in forms and reports but we want the seconds
value in your tableMake sure (if appropriate) that your times follow on from each other,
otherwise your text box will be blank if there is no current shift - which
is what you want.
Shift1 09:00:01 to 12:00:00
Shift2 12:00:01 to 16:00:00
Shift3 16:00:01 to 20:00:00Have I got the right idea about what you are trying to do?I've commented out the Echo lines. It seems to make the whole form blink
whereas the Requery event just makes the text box itself blinkEnsure that your Timer Interval in Properties is no less than 5000 so that
it refreshes every 5 seconds. If you don't have to be that precise then have
it refresh less often, say 10000, to cut down on the 'blinks'.Evi- Hide quoted text -- Show quoted text -
Hi Evi,
Lots of good advice. Okay...got a little confused yesterday.
The table name is ShiftTime. (I made an error yesterday)
Fields in the table are:
ShiftTimeID (autonumber field)
ShiftTime
StartofShift
EndofShift
My shift times follow the shifts in the plant which are
Start: 7:00am end: 4:30pm - Day Shift
Start: 5:45pm end: 3:15am - Aft. Shift
So my Dlookup looks like this:
=DLookUp("[ShiftTime]","ShiftTime","TimeValue([StartofShift])<= #" &
TimeValue(Now()) & "# AND TimeValue([EndofShift]) >= #" &
TimeValue(Now()) & "#")
I have this Dlookup in the Control source of my txtShiftName in my
form, but, I am still getting a blank response to my text box. Has
this got to do with my start and end of shift times based on what you
wrote
above:
"eg
Shift1 09:00:01 to 12:00:00
Shift2 12:00:01 to 16:00:00
Shift3 16:00:01 to 20:00:00"
So, I will try to alter my shift times to see if it works.- Hide quoted text -
- Show quoted text -
Nope, didn't work...... :-(
Try making the Dlookup less complex just for test purposes
=DLookUp("[ShiftName]","ShiftName","TimeValue([StartofShift])<= #" &
TimeValue(Now()) & "# AND TimeValue([EndofShift]) >= #" & TimeValue(Now()) &
"#")
=DLookUp("[ShiftName]","ShiftName") (it should just look up a shift name)
then
=DLookUp("[ShiftName]","ShiftName","TimeValue([StartofShift])<= #" &
TimeValue(Now()) & "# )
It'll look up any shift start time which comes before the current time
is your table (or query) name actually "ShiftName"?
I wonder if you have a date hidden in your shift times (although I had hoped
that TimeValue would sort that out). Make sure that *in the Table Design*,
on the Format line for StartOfShift and EndOfShift you type
hh:nn:ss
Just for test purposes, change the shift times so that one includes the time
when you are testing
Do you have anything else in StartOfShift, EndOfShift other than the time?
Are they actually Date/Time fields?
Record 1 should be:
StartOfShift: 07:00:00
EndOfShift: 16:30:00
Record 2 should be
StartOfShift: 17:45:00
EndOfShift: 03:15:00
The text box, of course, will be blank if you test it at any time other than
those in your table.
Make sure your Timer Interval is no less than 5000. (Make it 20000 to start
with, just for testing)
Try testing Now() and TimeValue on your PC by having a text box say
=#17:00:00#>TimeValue(Now())
Depending on when you do this, the answer should be either 0 for untrue
or -1 for true
I've got this working so I know it is possible.
Evi