Hi,
I have a really simple form bound to a table that I want to bulletproof for plant operators to enter data. There are five fields arranged in a column under a heading of "Current" which is where the operator will type in the data, and then next to that I have some unbound, disabled, text boxes that are populated from the last record that was entered under a heading of "Most Recent". I haven't yet, but I will remove the record navigation buttons to stop operators scrolling back and "fiddling" historical data. (There is another read-only form to view historical data.) There are three cmd buttons - "New", "Save" and "Close". New clears the textboxes and then populates the first two with a sequential furnace tap number (1 greater than the most recent one) and today's date respectively. The operator will then fill in the time, temperature and tons tapped from the furnace and click on "Save" to submit the record.
I haven't written the few lines of code to do the save yet, but when I click on the record selector to submit the record, I use the "Before Update" event to check that all the fields are filled in with valid data. If something is missing, I cancel the update event and give an appropriate message and return to the form. If all the data is in order, I want to use the "After Insert" event once the new record has been added to populate the unbound textboxes with the latest info and to move to a new record, but not yet populate the first two fields with anything in case there is no more data to be added at that point. If there is more data, then the operator must click on "New" again and the process is repeated.
The code I tried is :
Private Sub Form_AfterInsert()
PopulateRecent 'Copies the relevant fields from the most recent record to the unbound textboxes
Me.Requery
DoCmd.GoToRecord , , acNewRec
End Sub
I don't know if the "Requery" is necessary, but since I am moving to a new record, I didn't think it would matter whether it was there or not. Now here is the problem - once the above code has finished running, the record selector has the focus and the record indicator is on the last record entered. Stepping through the code, when I execute the "acNewRec" line, the form is exactly as I want it - sitting and waiting on a new blank record. When I execute the final "End Sub", the focus jumps to the record selector and the record counter decreases by one back to the last record. Why can't I get the form to sit and wait on a new blank record for input ?
I tried the above code on the "After Update" event as well to no avail. I haven't tried opening the form in data entry mode yet - I don't know if I could use that feature to get around this hassle?
Any ideas please ? I am sure I am missing something really obvious !
All this because I don't want the operator to use the >* to add a new record <img src=/S/doh.gif border=0 alt=doh width=15 height=15>
Thanks,




