Hi All,
I hope this is a fairly simple on for those of you in the know.. I have been struggling with this for a few days now and it is driving me mad!
I have modified the northwind database to use it for my own system. I have an issue with the orders form. I have a new unbound text box control called [totalpaid]
and I want to copy the data from the orders [total] field. The total field works out the total based on a sum in the footer of the order details subform.
A command button with the onclick event code Me.totalpaid = Me.Total does the job perfectly, or so I thought!
If the user updates an item in the subform, say [unitprice] for example, and leaves the cursor in the [unitprice] field without pressing tab or enter, then clicks straight on my command button (located on the main form) the main form doesn't get the total from the subform untill after the buttons code has copied the incorrect total from the [total] textbox control.
So I thought it would just need to be refreshed, so I added "Me.refresh" to the buttons code, but it seems to run through the code in the wrong order and copies the data before the form refreshes!
If I add a separate refresh button, click that and then click my copy button it works fine! But I need this to work from one button. So.. In a nutshell:
Is there code that can make my button do the following
1. Refresh the form
2. Wait for the form to refresh
3. Copy the value from the Total field to the Totalpaid field.
_____________
This works if I do it manually
1. Click on the refresh button : Runs the code "Me.Refresh"
2. Wait for a split second for the field to calculate.
3. Click on the copy button : Runs the code "Me.totalpaid = Me.Total"
but if I combine these two lines to make:
Me.Refresh
Me.totalpaid = Me.Total
The form doesn't refresh till after the copy and the calculated field has the wrong value.
Hope this makes sense guys, it really is driving me mad! I am very much a beginner in visual basic so I know I am probably just doing something stupid!
Thanks in advance!
Adam