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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform ignores MoveLast command after adding a record

Status
Not open for further replies.

Baggie

Technical User
Jun 11, 2002
25
US
I am using Access 2000 and I have a tabbed form. On one tab I have a subform in datasheet view (The mainform is customers, the subform is invoices) When a user adds a record to the invoice subform I have code in the last control's exit event that performs some calculations on the main form. This is the last line in my code for the subform exit event:

Code:
Forms!frmInputTabs!frmInvoice.Form.Recordset.MoveLast

Now, when I move off the firing control event and no new record is added it will move to the last record. However, when I add a new record it seems to ignore that code and pops to the first field of the first record.

Thanks in advance for any ideas!

Baggie
 
It sounds like it is ignoring the MoveLast when you add a new record because it is already at the last record. Why do you want to move to the last record? Perhaps there is another way to accomplish what you are trying to do. By the way, it might be better to move your code that performs the calculations to the SubForm's On Current or After Update event. What happens if the user doesn't enter any data in the last field? dz
dzaccess@yahoo.com
 
FoxProProgrammer:

I tried to make it move to a new record but it also ignores that. I want the cursor to be at the bottom in case they want to add another record. (It could be reallying annoying to the user to always have to scroll down from the top to enter a new one. Especially, if you've got a lot of records). You may have something with moving the code to some other event. (BTW, what does the ON CURRENT event do anyway?)
Lastly, the user is forced to enter data in the last field because it's critical to the calculation.

Thanks for your response
 
If you want to display a new record in your form (all fields blank), try this:

DoCmd.GoToRecord acDataForm, "Your form name", acNewRec

The On Current event triggers when the record pointer changes or when a form is requeried.

As long as the user is forced to enter something in the last field before the record is saved, it might be ok to leave your code in the Exit event of the text box. I just think that it is cleaner to execute that kind of code when you save the record, and not when you exit a field. This is really just a style issue, and one way isn't necessarily better than the other. dz
dzaccess@yahoo.com
 
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Requery
'or maybe Me.Refresh instead
Forms!frmInputTabs!frmInvoice.Form.Recordset.MoveLast

Try that. If it doesn't work, I'll actually setup a form like yours and have at it.

-Josh ------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top