Cash register

G

Guest

I have Access 2003: I am new to access and trying to make a form work as a
cash register. I have a subform in my main form. This sub form brings up
both services and retail, and for each line,(which is called "ExrendedPrice",
I have it calculated to give me the correct amount for item and quantity
minus discount. That part is working. There is also a field that says
"Taxable?". Services come up "no", retail comes up "yes".
What I need is (I think) to get two different subtotals, one of services one
of retail.

Having no idea, I tried things such as:
SubtotalTax=Sum([Taxable?] Like "Yes") [Extended Price]
SubtotalTax=(Like "Yes"[Taxable?])Sum[ExtendedPrice]

The opposite would be the same with "No" in it.
Can any one help? I will then take these subtotals into my main form:

=[ProductExtendedSubform].FORM! SubtotalTax*[Sales Tax Rate]
??????
Thanks for the help.
M.Hayward
 
T

tina

if SubtotalTax is the name of an unbound control in the footer of the
subform, then try this expression in the control's ControlSource property,
as

=Sum(IIf([Taxable?] = "Yes", [ExtendedPrice], 0)

the above expression assumes that the field [Taxable?] is a Text data type
(in the underlying table). if the field's data type is Yes/No, then try

=Sum(IIf([Taxable?] = True, [ExtendedPrice], 0)

or

=Sum(IIf([Taxable?] = 0, 0, [ExtendedPrice])

the expression for your *main* form's unbound control looks correct, as long
as [ProductExtendedSubform] is the name of the subform *control*. sometimes
the subform control and the subform object in the database window have the
same name, sometimes not. to make sure you're using the name of the subform
control:

1. open the main form in design view.
2. click on the subform (within the main form design view) once, to select
it.
3. open the Properties box and click on the Other tab.
4. look at the Name property; that's the name of the subform control.

hth
 
G

Guest

Thank you, that did the trick. And I got the rest of the expressions, order
sutotal, tax, total ect working as well.
M

tina said:
if SubtotalTax is the name of an unbound control in the footer of the
subform, then try this expression in the control's ControlSource property,
as

=Sum(IIf([Taxable?] = "Yes", [ExtendedPrice], 0)

the above expression assumes that the field [Taxable?] is a Text data type
(in the underlying table). if the field's data type is Yes/No, then try

=Sum(IIf([Taxable?] = True, [ExtendedPrice], 0)

or

=Sum(IIf([Taxable?] = 0, 0, [ExtendedPrice])

the expression for your *main* form's unbound control looks correct, as long
as [ProductExtendedSubform] is the name of the subform *control*. sometimes
the subform control and the subform object in the database window have the
same name, sometimes not. to make sure you're using the name of the subform
control:

1. open the main form in design view.
2. click on the subform (within the main form design view) once, to select
it.
3. open the Properties box and click on the Other tab.
4. look at the Name property; that's the name of the subform control.

hth


M.Hayward said:
I have Access 2003: I am new to access and trying to make a form work as a
cash register. I have a subform in my main form. This sub form brings up
both services and retail, and for each line,(which is called "ExrendedPrice",
I have it calculated to give me the correct amount for item and quantity
minus discount. That part is working. There is also a field that says
"Taxable?". Services come up "no", retail comes up "yes".
What I need is (I think) to get two different subtotals, one of services one
of retail.

Having no idea, I tried things such as:
SubtotalTax=Sum([Taxable?] Like "Yes") [Extended Price]
SubtotalTax=(Like "Yes"[Taxable?])Sum[ExtendedPrice]

The opposite would be the same with "No" in it.
Can any one help? I will then take these subtotals into my main form:

=[ProductExtendedSubform].FORM! SubtotalTax*[Sales Tax Rate]
??????
Thanks for the help.
M.Hayward
 
G

Guest

My next questions..... Now that my expressions are working and I was able to
play with pretend sales, I realize these amounts or totals don't go to my
clients info as I had hoped. Is there a way to make "sales tax" ,"order
total", and "Balance due" to go into my clients History? The "tip" does as
well as "Total Payments" because those numbers will be ones I put in, not
calculated.

I hope this makes sense, Thanks for the help.
Marguerite
 
T

tina

general rule of thumb is that you save "raw" numbers as hard data (in a
table), but not calculated numbers - you calculate those values on-the-fly
as needed, from the raw numbers that you saved.

sometimes there is a valid business reason for saving calculations as hard
data. if you choose to do so, then there are a number of ways to do it.
again generally speaking, if i were entering raw data into a record via a
form and wanted to calculate values from that data and save it in the record
at the same time, i would not use calculated controls to display the
calculated values. instead, i would probably write VBA code to calculate the
values at appropriate data entry points, and assign the values to textbox
controls bound to the appropriate fields in the form's underlying table.

hth
 
G

Guest

WOW, I think VBA is way beyond me. I will play with seeing if I end up with
enough "raw" data save to get the other answers witha queery. But I am not
even getting the date of my sales saved as the control on the form is now
=Date() , so that does not go back to my table. I'm puzzeled now but am sure
I will be back with more questions when I play some more.
Thanks
Marguerite
 
T

tina

simple VBA procedures are not as hard as you think, many times you can
accomplish what you need with just a line or two of simple code. for
example, if i wanted to save "unit cost x number of units" total into a
field in my table, i would do the following: in the form's BeforUpdate
event, add a line of code to set the value of the TotalCost field, as

Me!TotalCost = Me!UnitCost * Me!NumberOfUnits

but sometimes you don't need even that. for instance: if you have a date
field in your Sales table, and in your data entry form you're showing
today's date when you enter a record, DON'T use a *calculated* control.
instead, set the control's ControlSource to the name of your date field
(from the property's droplist). then set the control's DefaultValue to
Date(). each new record you enter will be stamped with today's date, a
"hard" value which will be saved into the record.

hth
 
G

Guest

Thanks again for your help. The below example of what to do for the Date
looks like it is working. I tried the same idea for my other fields, but it
did not. I tried similar to what you did with the Me! etc but that didn't
work the way I did it anyway. I am sending you the expressions in my other
boxes and see what you think. How t change them to make them go in hard copy
that is.

OderSubtotal
=[Prod Extended Details Subform2].[Form]![Text14]+[Prod Extended Details
Subform2].[Form]![Text16]

SalesTax
=([Prod Extended Details Subform2].[Form]![Text14]*[Text26]*100)/100

Tip is put in a not calclated field

OrderTotal
=[OrderSubtotal]+[SalesTax_Label]+[Tip]

TotalPayments is also put in like tip

BalanceDue
=[OrderTotal]-[TotalPayments]
I need to check again, but I think I just noticed that if my sales tax say
is 1.25 and not just 1.00 it is not adding the .25 in my Order Total.

What can I do to get these total to go back in my tables?
You are great. How long have you been doing this, if I'm alowed to ask.
Marguerite

"> Me!TotalCost = Me!UnitCost * Me!NumberOfUnits
 
G

Guest

I was wrong about the sales tax, I had it wrong it wasn't adding at all.
So correction where is says "SalesTax_Label" that is wrong, it should
only say "SalesTax"

Thanks again.

M.Hayward said:
Thanks again for your help. The below example of what to do for the Date
looks like it is working. I tried the same idea for my other fields, but it
did not. I tried similar to what you did with the Me! etc but that didn't
work the way I did it anyway. I am sending you the expressions in my other
boxes and see what you think. How t change them to make them go in hard copy
that is.

OderSubtotal
=[Prod Extended Details Subform2].[Form]![Text14]+[Prod Extended Details
Subform2].[Form]![Text16]

SalesTax
=([Prod Extended Details Subform2].[Form]![Text14]*[Text26]*100)/100

Tip is put in a not calclated field

OrderTotal
=[OrderSubtotal]+[SalesTax_Label]+[Tip]

TotalPayments is also put in like tip

BalanceDue
=[OrderTotal]-[TotalPayments]
I need to check again, but I think I just noticed that if my sales tax say
is 1.25 and not just 1.00 it is not adding the .25 in my Order Total.

What can I do to get these total to go back in my tables?
You are great. How long have you been doing this, if I'm alowed to ask.
Marguerite

"> Me!TotalCost = Me!UnitCost * Me!NumberOfUnits
Date(). each new record you enter will be stamped with today's date, a
"hard" value which will be saved into the record.

hth
 
G

Guest

Another question:
What do I change so that my client info when it is pulled up on the form can
not be "accidently" changed. But I need to be able to edit and add when I
need to?

Thanks agan,
Marguerite
 
G

Guest

Another question:
What do I change so that my client info when it is pulled up on the form can
not be "accidently" changed. But I need to be able to edit and add when I
need to?

Thanks agan,
Marguerite
 
T

tina

well, let's see. i'm guessing that Text14 and Text16 are calculated controls
in the footer of their subform. i'm also guessing that means that the raw
data to calculate those totals is saved in the table underlying that
subform. which means that you have the raw data saved to calculate
OrderSubtotal when you need it, and probably don't have a business reason to
save the OrderSubtotal as hard data.

ditto for SalesTax, based on Text14 and Text26.

if you can calculate OrderSubtotal and SalesTax from raw data, and presuming
that the value of Tip is saved as hard data, then you can also calculate
OrderTotal as needed.

presumably TotalPayments may change over time, as the customer pays some of
the total, and then more of the total? if so, i definitely would not save a
BalanceDue as hard data, because that value will keep changing until the
order is completely paid for - updating hard values like that in a timely
manner can be very difficult and fraught with potential for error, depending
on the circumstances, which will *not* endear you to your customer.

a valid business reason for saving a total might be, for instance, saving
the SalesTax value - because the sales tax rate may change over time, and
you need valid values in your historical records. even in that case, i'd be
more likely to save the sales tax percent as hard data in a record, and
calculate the sales tax value as needed to display the record. (that would
be a KISS solution; you can do more complex setups to pull the appropriate
rate based on the date of an order, but no point confusing you with that
now.)

having said all the above, and i hope you consider those points carefully in
light of your particular situation, here's one way to update fields in the
main form record from calculated values in a subform:

in Subform2's AfterUpdate event procedure (make sure you're in Subform2's
module, not the main form's module), try the following code, as

With Me
If Not IsNull(!Text14) And Not IsNull(!Text16) Then
.Parent!OrderSubtotal = !Text14 + !Text16
End If
End With

here's how the code works:
With Me
End With
simply says that all the field and property references between those two
lines is understood to belong to this module's form. "Me" refers to the form
you're working in. using With Me, allows you to avoid declaring the the form
as Me, in every single field and property reference. it mainly just saves
some typing keystrokes and maybe makes the code a little easier to read.

the If statement pretty much works like the IIf() function that you may be
familiar with using in forms and queries. it says, in essence "If Text14 is
not null and Text16 is not null, then add those two together and update the
OrderSubtotal field on the parent form (the main form)." this If statement
has no "Else" section, because in this case we don't need it.

so what happens is, every time you add or edit a record in the subform, the
AfterUpdate event will fire, running the code. the code looks at Text14 and
Text16, and if there are values in both controls, then the field on the
parent form will be updated with the sum of those two controls.

the SalesTax total is somewhat different, because Text14 is a control on the
subform, while Text26 looks to be a control on the main form - correct? if
so, the syntax would be

With Me
If Not IsNull(!Text14) And Not IsNull(.Parent!Text26) Then
.Parent!OrderSubtotal = (!Text14 * .Parent!Text16) * 100) / 100
End If
End With

again, the the syntax for how you refer to a control depends on which form
the control is located in AND which form module the code is in.
I need to check again, but I think I just noticed that if my sales tax say
is 1.25 and not just 1.00 it is not adding the .25 in my Order Total.

make sure that any table field that needs to contain decimals is either a
Double or Currency (if it contains money) data type. you have to set this at
the table level in order for the field size to be correct and allow the
complete values to be saved.

hth


M.Hayward said:
Thanks again for your help. The below example of what to do for the Date
looks like it is working. I tried the same idea for my other fields, but it
did not. I tried similar to what you did with the Me! etc but that didn't
work the way I did it anyway. I am sending you the expressions in my other
boxes and see what you think. How t change them to make them go in hard copy
that is.

OderSubtotal
=[Prod Extended Details Subform2].[Form]![Text14]+[Prod Extended Details
Subform2].[Form]![Text16]

SalesTax
=([Prod Extended Details Subform2].[Form]![Text14]*[Text26]*100)/100

Tip is put in a not calclated field

OrderTotal
=[OrderSubtotal]+[SalesTax_Label]+[Tip]

TotalPayments is also put in like tip

BalanceDue
=[OrderTotal]-[TotalPayments]
I need to check again, but I think I just noticed that if my sales tax say
is 1.25 and not just 1.00 it is not adding the .25 in my Order Total.

What can I do to get these total to go back in my tables?
You are great. How long have you been doing this, if I'm alowed to ask.
Marguerite

"> Me!TotalCost = Me!UnitCost * Me!NumberOfUnits
Date(). each new record you enter will be stamped with today's date, a
"hard" value which will be saved into the record.

hth


up
with am
not am
sure as
hard via
a the
record calculate
the was
able go to
my "tip"
does in,
not
 

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

Similar Threads

Confused with report... 2
Tax Box Problems 3
Invoice Form Setup Help 1
#Error on form 2
Iff statement 9
Extended Price: 3
Sum problem 1
Subform (Datasheet) Calculation (Syntax) Issues 1

Top