By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,478 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

AfterUpdate() to make previous record values the default of new record

P: 161
I need to carry my "stop" data forward to each new records "start" and "stop" controls so they values are equal to begin with.

The code below carries only the stop to stop values of "me.txtname.defaultvalue" to the new record. Is there something I can do to the code for it to carry the stop value to the start value as well? Also it seems to stop working once the form has been closed. Any suggestions? Thanks

Expand|Select|Wrap|Line Numbers
  1. 'Default Value of Fuel Start & Stop
  2. Private Sub txtFuelStart_AfterUpdate()
  3. Me.txtFuelStart.DefaultValue = """" & Me.txtFuelStop.Value & """"
  4. End Sub
  5. Private Sub txtFuelStop_AfterUpdate()
  6. Me.txtFuelStop.DefaultValue = """" & Me.txtFuelStop.Value & """"
  7. End Sub
  8. 'Default Value of NG Start & Stop
  9. Private Sub txtHeatNGStart_AfterUpdate()
  10. Me.txtHeatNGStart.DefaultValue = """" & Me.txtHeatNGStop.Value & """"
  11. End Sub
  12. Private Sub txtHeatNGStop_AfterUpdate()
  13. Me.txtHeatNGStop.DefaultValue = """" & Me.txtHeatNGStop.Value & """"
  14. End Sub
  15. 'Default Asphalt Tank 1 Inches Start & Stop
  16. Private Sub cboAsphStart1_AfterUpdate()
  17. Me.cboAsphStart1.DefaultValue = """" & Me.cboAsphStop1.Value & """"
  18. End Sub
  19. Private Sub cboAsphStop1_AfterUpdate()
  20. Me.cboAsphStop1.DefaultValue = """" & Me.cboAsphStop1.Value & """"
  21. End Sub
  22. 'Default Asphalt Tank 2 Inches Start & Stop
  23. Private Sub cboAsphStart2_AfterUpdate()
  24. Me.cboAsphStart2.DefaultValue = """" & Me.cboAsphStop2.Value & """"
  25. End Sub
  26. Private Sub cboAsphStop2_AfterUpdate()
  27. Me.cboAsphStop2.DefaultValue = """" & Me.cboAsphStop2.Value & """"
  28. End Sub
2 Weeks Ago #1
Share this Question
Share on Google+
5 Replies

Expert Mod 15k+
P: 31,273
This is a much better question. It only has two questions in it :-D We can handle that ;-)
Let me post my suggestion as code so you can examine the differences and see more than just one thing :
Expand|Select|Wrap|Line Numbers
  1. 'Default Value of Fuel Start & Stop
  2. Private Sub txtFuelStop_AfterUpdate()
  3.     With Me.txtFuelStop
  4.         Me.txtFuelStart.DefaultValue = "='" & .Value & "'"
  5.         .DefaultValue = "='" & .Value & "'"
  6.     End With
  7. End Sub
  9. 'Default Value of NG Start & Stop
  10. Private Sub txtHeatNGStart_AfterUpdate()
  11.     With Me.txtHeatNGStop
  12.         Me.txtHeatNGStart.DefaultValue = "='" & .Value & "'"
  13.         .DefaultValue = "='" & .Value & "'"
  14.     End With
  15. End Sub
  17. 'Default Asphalt Tank 1 Inches Start & Stop
  18. Private Sub cboAsphStart1_AfterUpdate()
  19.     With Me.cboAsphStop1
  20.         Me.cboAsphStart1.DefaultValue = "='" & .Value & "'"
  21.         .DefaultValue = "='" & .Value & "'"
  22.     End With
  23. End Sub
  25. 'Default Asphalt Tank 2 Inches Start & Stop
  26. Private Sub cboAsphStart2_AfterUpdate()
  27.     With Me.cboAsphStop2
  28.         Me.cboAsphStart2.DefaultValue = "='" & .Value & "'"
  29.         .DefaultValue = "='" & .Value & "'"
  30.     End With
  31. End Sub
Also it seems to stop working once the form has been closed. Any suggestions?
You could save the design of the form when you close it but I wouldn't actually advise that. There are various situations where that could cause you problems. I would say just live with it, but if it's not as straightforward as it appears (to me at least) then post it separately and we can delve into it more deeply. There are options available to change the design of the table itself but loads of potential complications there too. We'd need more detail if you need to progress this further.
2 Weeks Ago #2

P: 161
Neo itís simply for convenience. If itís advisable to not try to carry over data I can use the Ctrl + Ď option. Just something to prevent me having to click between records. On inventory items the previous ending is the new records beginning. I certainly donít wont to encounter errors the could cascade by trying to code it.
2 Weeks Ago #3

Expert Mod 15k+
P: 31,273
Let's start with a quick reminder to read and edit your posts before leaving them. This one makes it quite hard to follow what you're trying to say.

In response to your comment I would say that code to set it in the Open Event of the form would hardly be complicated. Let us know, by posting the question fully elsewhere, if you'd like to progress with that. We'd need to know how the data is stored so we can determine how to find it when the form's opened.
2 Weeks Ago #4

P: 161
Hey. I just understood that if I could live with it that it wasnít advisable. Rather than after update you recommend open event. If it will solve the question than Iíd be happy to try it.
2 Weeks Ago #5

Expert Mod 15k+
P: 31,273
Did I misunderstand you? I wasn't suggesting an alternative approach but an additional one.

The AfterUpdates seem fine as they are to keep things going properly within a session but if you need/want to persist these between sessions then you really want to add some code to ensure that it starts in the right place as well. Does that make sense? Also is it something you're still interested in?
2 Weeks Ago #6

Post your reply

Sign in to post your reply or Sign up for a free account.