G
Guest
I need help with a form in Access 2000. My (bound) form has 12 text boxes for
Jan-Dec and a text box for the year total. These text boxes are bound to an
underlying query. I have placed an unbound text box on the form. In this text
box, I want the user to be able to enter an amount. This amount will be
divided by 12 and the result will populate the Jan - Dec text boxes. The
amount entered in the unbound box will populate the year total text box.
I want the user to be able to enter amounts in the Jan-Dec fields OR use the
text box that will split it equally for them.
I have written code in the unbound text box's BeforeUpdate event that checks
to see if the year's total box is 0, if so, take the value entered and divide
by 12, populate the Jan-Dec text boxes.
Elseif the value is greater than 0, then I have a msgbox that tells them the
existing data will be overwritten, do they want to continue? Ok or Cancel.
This is where I have a nested if statement. If the vbmsgboxresult is cancel
then I use the cancel = true line. If the result is Ok, then divide the
number by 12 and put it in Jan-Dec.
It doesn't work right. I've tried putting the If statment in the "Enter"
event, to evaluate the year total box to see if there is an amount greater
than 0 in there. This works good, but I still can not get the nested msg box
results to work.
I also have a subform based on a totals query, linked to the main form, that
shows the new year total. I would like for it to update as well. If I use the
Requery code, it runs the code again, I think because the focus is still on
the unbound text box at this point.
(and I would like to reset the amount in the unbound text box to zero when
it goes to the next record... do that in the form events?)
Can you suggest a better way? I sure will appreciate it. Thanks very much.
Donna
Jan-Dec and a text box for the year total. These text boxes are bound to an
underlying query. I have placed an unbound text box on the form. In this text
box, I want the user to be able to enter an amount. This amount will be
divided by 12 and the result will populate the Jan - Dec text boxes. The
amount entered in the unbound box will populate the year total text box.
I want the user to be able to enter amounts in the Jan-Dec fields OR use the
text box that will split it equally for them.
I have written code in the unbound text box's BeforeUpdate event that checks
to see if the year's total box is 0, if so, take the value entered and divide
by 12, populate the Jan-Dec text boxes.
Elseif the value is greater than 0, then I have a msgbox that tells them the
existing data will be overwritten, do they want to continue? Ok or Cancel.
This is where I have a nested if statement. If the vbmsgboxresult is cancel
then I use the cancel = true line. If the result is Ok, then divide the
number by 12 and put it in Jan-Dec.
It doesn't work right. I've tried putting the If statment in the "Enter"
event, to evaluate the year total box to see if there is an amount greater
than 0 in there. This works good, but I still can not get the nested msg box
results to work.
I also have a subform based on a totals query, linked to the main form, that
shows the new year total. I would like for it to update as well. If I use the
Requery code, it runs the code again, I think because the focus is still on
the unbound text box at this point.
(and I would like to reset the amount in the unbound text box to zero when
it goes to the next record... do that in the form events?)
Can you suggest a better way? I sure will appreciate it. Thanks very much.
Donna