Calculated field

L

LindaBee

SORRY IF I HAVE POSTED THIS ELSEWHERE DONT KNOW HOW TO POST SO THAT THE QUERY
GOES TO MULTIPLE GROUPS

Hi All

I have a puzzling problem and I cannot figure out where I am going wrong
perhaps the experts can help me out here!

I have created a form in my database that calculates payment based on the
value in one field. I have a field called Question1A and a Text field called
Text1A I enter a value in Question1A and the calcualtions are displayed in
Text1A and the I have 2 ore fields Question2B and Text2B the combined values
in Question1A and Question1B calculate This works ok except when I enter a
new record the values from the previous record are displayed and I have to
refresh the screen for the default values to be displayed.

I have tried enterring the calculations in the before and after update and
on form load

Question1A and Question1B are both manual entries by user

here is a sample of the code


The first function calculates what goes into Text1A

Private Sub Question1A_BeforeUpdate(Cancel As Integer)

If Me.Question1A = "A" Then
Me.Text1A = 12* 0
Else
If Me.Question1A = "B" Then
Me.Text1A = 12* 0.5 * 3
Else
If Me.Question1A = "C" Then
Me.Text1A = CalculatorField * 4 * 0.5
Else
End If
End If
End If

what goes into Text1B

Private Sub Question1B_BeforeUpdate(Cancel As Integer)
If Me.Question1A = "A" And Me.Question1B = "1" Then
Me.Text1B = Me.Text1A * 2
Else
If Me.Question1A = "A" And Me.Question1B = "2" Then
Me.Text1B = Me.Text1A * 4
ElseIf Me.Question1A = "B" And Me.Question1B = "1" Then
Me.Text1B = Me.Text1A * 6
Else
If Me.Question1A = "B" And Me.Question1B = "2" Then
Me.Text1B = Me.Text1A * 8
Else
End If
End If
End If


Please please HELP!!!
 
B

BruceM

Post in multiple groups by adding the group names to the group name in the
header. I have no way of knowing whether you have already received an
answer unless I search other (unspecified) groups, so I will keep this brief
in case I am already wasting my time or yours.

Also, please use punctuation, and lay off the cap locks key. No need to
shout. You should take a look at this:
http://www.mvps.org/access/netiquette.htm

Maybe you can sort of get away with the design you are using as long as you
never have Question3 or Question4. As it is you are using a table like it
is a spreadsheet, which can be very difficult to maintain as changes are
made.

If Text1A, etc. are unbound you could get the behavior you describe. If
they are bound to fields in the table I don't see offhand how the value is
being carried to the new record. If they are unbound you just need to reset
them in the form's Current event. This should work:

Me.Text1A = ""

You could use a different event as needed, but the point is you need to
clear the text box each time.
 
N

ntc

well an unbound field retains its data when changing records - - that's a
good thing or a bad thing depending on what you need....

you just need to clear it out using the OnCurrent event of the form with
something like:

me.UnboundFieldName=""
 
L

LindaBee

This has worked thanks both for all your help

ntc said:
well an unbound field retains its data when changing records - - that's a
good thing or a bad thing depending on what you need....

you just need to clear it out using the OnCurrent event of the form with
something like:

me.UnboundFieldName=""
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top