New Auto Limited Record

boyaqoub

New member
Local time
Today, 09:36
Joined
Jun 4, 2018
Messages
2
HI

im trying to make Daily LogBook to my Work,

i created the table and 2 Form for it,

i want 1 for that only viewing past record no editing,

and for the second i want it to be

Auto add new record from 6:00 am to 2:00 pm, and then auto save..

i want the form stay in for 8 hour,, even if you save it, it will not be in viewing form unit 2:00pm
"so it will be limited for workers to write every thing daring the 8 hours"

Please help me and thank you all
 
1. In the Form's On Dirty event, check to see if this is a new record.
Code:
If Me.NewRecord = False
        Me.Undo
        Cancel = True
        Exit Sub
End If
2. It is a bad idea to create empty records. Your BeforeUpdate event should always include validation that verifies that required data exists.
3. A form will stay open unless someone closes it.
4. If the workers make multiple entries to log what they are doing, they should be creating multiple records not logging everything into a single record.
 
for number 2, it's will be new record "last record"
for number 4, there will be no multiple entries to the same form,

the thing is i only want "limited record",

it's for Morning from 6:05am to 2:05pm
for afternoon from 2:05pm to 10:05pm
and for night from 10:05pm to 6:05am

every record will have time on it like "morning shift", "afternoon shift","night shift"

the code will be in load form.

If the date not = last record && last record = night shift && time between 6:05 to 2:05
Then create new record <<< It's will be Morning shift then,
 
Is everyone using the same computer? Do they reboot it at shift change? Do the users log in to the application? How do you know who is making the entry if they don't log in or reboot?

It is better to create the record on a button push rather than on form load. If you do it on form load, you will be creating bogus records if you use the same form for viewing as well as adding records. That way the actual user should be logged in and you'll know who it is. You can check the current time of day and determine from that what the shift is and what day you want to record. I'm assuming for 12:00 AM - 6:05 AM you want to use yesterday's date.

See if this gets you started. You would call it from the click event of the button so that it only adds a new record when the user actually wants to add one. It gives the flexibility of adding the record any time in the shift.

Code:
Public Function CheckTime() As String
    Select Case DateValue(Now())
        Case #6:05:00 AM# To #2:04:00 PM#
            CheckTime = "morning shift - " & Date
            Me.ShiftStart = Date + #6:05:00 AM#
            Me.ShiftEnd = Date + #2:05:00 PM#
        Case #2:05:00 PM# To #10:04:00 PM#
            CheckTime = "afternoon shift - " & Date
            Me.ShiftStart = Date + #2:05:00 PM#
            Me.ShiftEnd = Date + #10:05:00 PM#
        Case #10:05:00 PM# To #11:59:00 PM#
            CheckTime = "evening shift - " & Date
            Me.ShiftStart = Date + #10:05:00 PM#
            Me.ShiftEnd = Date + 1 + #6:05:00 AM#
        Case Else
            CheckTime = "evening shift - " & Date - 1
            Me.ShiftStart = Date - 1 + #10:05:00 PM#
            Me.ShiftEnd = Date + #6:05:00 AM#
    End Select
End Function
 
What business goal is accomplished by adding in ONE record for a given time period?

This type of "Auto added record" is normally seen when a system needs a "Parent" for all transactions in a shift and the developer is trying to find a handy place to store periodic totals.
 

Users who are viewing this thread

Back
Top Bottom