Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repeat Data in Forms

Status
Not open for further replies.

clem

Technical User
Dec 5, 2000
38
0
0
US
I have been struggling with this for over 24 hours now. No one has yet answered my first post - I'm not complaining, just desperate at this point. Is there ANYONE who can give me direction? I would be very grateful. Please see the following:

Is it possible to have the FIRST value (default on first entry only)in a control on a form be different than the rest of the values that will be entered for the same control?

This part of the form is a sub-form and linked with with the main form with an autonumber. The mainform has Autonumber - Date - Shift- Machine Operator and Product being run. The subform is in datasheet view and needs to remain open during the 12 hour period, adding many line entries during the period - then the form will be closed when the new shift comes in for them to begin their 12 hour activity.

I need a form that when first opened, will have 7:30 AM (can skip the AM/PM stuff) hard-coded in the "StartTime" control; then before the form is closed at the end of a shift, the "EndTime" needs to be hard-coded to 7:30. This will hopefully help the operators not to skip any time periods.

My subform will have a "StartTime" control and an "EndTime" control (as well as YardsRun and DowntimeCode). There will be several entries for a 12 hour time period. We are trying to capture downtime versus production time for each shift.


EXAMPLE:
StartTime EndTime DowntimeCode YardsRun
7:30 8:45 25 0
8:45 9:10 Blank 2000
9:10 9:20 etc., etc. etc, until the shift is over 12 hours later.

Also, I need succeeding StartTime to default to the Previous EndTime (but only after the first entry)

How can I create my form to do what is needed? Any help will be greatly appreciated.
 
Try this: Set an input mask in your timefield to Medium Time.

In your form properties, OnOpen, write this code:

yournextbox.setFocus
me.timefield = "7:30 AM"

This will set your initial time at 7:30 AM and put the focus in the following box so you won't inadvertantly change it.

Then, in your events properties of your timefield, on GotFocus, write the code to change the value to Now().

me.timefield = Now()

When you do this, every time you go to the next line and enter the box, the value will automatically change to the current time.

The only problem I see is you will have to make sure the first record doesn't get changed.

Good luck. This worked for me in a continuous form. Hope it works for you.
 
Sorry. I didn't answer the Endtime problem. I think I'd fix that like this:

Add a yes/no box to the form. It can be unbound. In the AfterUpdate properties, write this code:

If Me.yesno = True Then
Me.timefield = "7:30 PM"
End If

When I did it, I set the default value to false. I'm not sure that will be necessary. The problem here is that your user will have to check that box on their last entry to get the time set to 7:30 PM.
 
Hi JJOHNS!

Firstly, thank you so much for responding to my post. I really appreciate you taking the time to help.

I'm going to need a little further help, if I could be a bother to you. Firstly, these entries won't be entered in "real time". They will probably be entered as the operator has time to record them, so the Time() will not work.

The idea of having the Yes/No command button will work wonderfully. But first, I have to get the other part perfected. This form I am working on has a main form with the date, operator, shift and productID. Then it is linked with the subform section via an autonumber. This subform is where the start & stop times are. When you have a form and subform together, I believe the subform opens before the form. When I tried your suggestion for the On Open Event, it works when I only open the subform independently, but when I open it as a complete form, the start time does not default to 7:30.

Respectfully,

Carol L. [ponytails]
 
Maybe if you use OnActivate instead of OnOpen. If that doesn't work, try OnLoad. If those don't work, I'm stumped.
The other Events properties won't work for just the first record.

If you don't want real time in the time fields, then just delete the default value. I would recommend leaving the input mask, however, to eliminate possible typos by your users.
 
If you followed the steps I've already given you, then all you have to do is set the default value of our StartTime to be equal to your EndTime. The OnActivate stuff will make it 7:30 AM the first time. From then on, it will be set to whatever the current value of EndTime is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top