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

Access, calculator control

P: 32
Hi,

I have a front screen till system which subtotals and runs fine. What i wish to do is the following:-

When the subtotal button is pressed a screen opens with the balance due, along with buttons numbered 1,2,3,4,5,6,7,8 and 9.

As each button is clicked, the "change due" or "outstanding balance" is shown.

There is no need for this data to be stored anywhere, its just a calculation.
May 10 '07 #1
Share this Question
Share on Google+
22 Replies


JConsulting
Expert 100+
P: 603
Hi,

I have a front screen till system which subtotals and runs fine. What i wish to do is the following:-

When the subtotal button is pressed a screen opens with the balance due, along with buttons numbered 1,2,3,4,5,6,7,8 and 9.

As each button is clicked, the "change due" or "outstanding balance" is shown.

There is no need for this data to be stored anywhere, its just a calculation.
so you will have a balance textbox..and when they click on a number, it subtracts from that? what if the user wants to subtract 20?
May 10 '07 #2

P: 32
the reason for the numbers 0 to 9 is not to limit their choice. Its because it will be operated on a touch screen system.

if the transaction value is 17.67, the user types 20, then a button called "tender", which in turn shows the difference between the two. The user can then click the screen to end the transaction
May 10 '07 #3

JConsulting
Expert 100+
P: 603
the reason for the numbers 0 to 9 is not to limit their choice. Its because it will be operated on a touch screen system.

if the transaction value is 17.67, the user types 20, then a button called "tender", which in turn shows the difference between the two. The user can then click the screen to end the transaction

This sounds fun. Just FYI, you didn't have 0 in your question.

So...first thing. Push the button to open the calculator

You will want to pass the balance to the new form. So we can do that with the opening arguement.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command2_Click()
  2. DoCmd.OpenForm "frmCalculator", acNormal, , , acFormReadOnly, acDialog, Me.MyBalance
  3. End Sub
  4.  
Now the calculator form itself.

I created an on_open event to load the balance

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2. Me.Balance = OpenArgs
  3. End Sub
  4.  
I created two textboxes. One called Balance, the other called Entry

I used the Format property and set them to Euro (Dollars/Pounds)

I created 10 buttons..called b1, b2, b3, etc...their captions 0-9. In each on_click event in the properties box, I put this call to the function...changing the number to the button's number
Expand|Select|Wrap|Line Numbers
  1. =myval(1)
  2.  
I created a function in the calculator form module (VBA)
Expand|Select|Wrap|Line Numbers
  1. Function MyVal(lnIn As Long)
  2. If Len(Me.entry) > 1 Then
  3. Me.entry = Replace(Me.entry, ".", "") & lnIn
  4. Me.entry = Left(Me.entry, Len(Me.entry) - 2) & "." & Right(Me.entry, 2)
  5. Else
  6. Me.entry = Me.entry & lnIn
  7. End If
  8. End Function
  9.  
I created 2 command buttons (I think you'll need a third to close the calculator too, but that one is easy)

Expand|Select|Wrap|Line Numbers
  1. Private Sub calc_Click()
  2. Me.Balance = Me.Balance - Me.entry
  3. Me.entry = ""
  4. End Sub
  5. Private Sub clear_Click()
  6. Me.entry = ""
  7. End Sub
  8.  
I made the form look like a calculator..and it still needs code so that when you close it....it updates the balance...but I need more info about how you want that to work.

This should get you going.
J
May 11 '07 #4

P: 32
Fantastic, think i understand, but to double check, heres something that i hope helps ut get closer.

1 form with all buttons for stock items, a sub form with a reciept (as you click its description and quantity tally up as you go.

another subform on the main form with the balance, which updates after each selection.

so with this in mind i would like the following to occur.....

1. When subtotal is clicked, a form (over unclosed button form) opens. (easy enough to do)

2. This form has the balance on one side (shown as a negative value which i guess would be achieve by subtracting its value twice from itself, but not sure how to do this)

3. The user selects the numbers which make the amount tendered, and clicks "tender"

4. Another form opens, showing the change due, and a button which will save and close the transaction
May 11 '07 #5

P: 32
Private Sub Command2_Click()
DoCmd.OpenForm "frmCalculator", acNormal, , , acFormReadOnly, acDialog,

Me.MyBalance

End Sub


it doesnt understand me.mybalance.

I have implimented all the code you gave, and hopefull close to getting this to work
May 11 '07 #6

JConsulting
Expert 100+
P: 603
Private Sub Command2_Click()
DoCmd.OpenForm "frmCalculator", acNormal, , , acFormReadOnly, acDialog,

Me.MyBalance

End Sub


it doesnt understand me.mybalance.

I have implimented all the code you gave, and hopefull close to getting this to work
me.mybalance was the field I was using to hold my balance. IT is passed as a value to the frmCalculator when it opens.

Where again is your "balance" field? and is it on your main form or your subform?
J
May 11 '07 #7

JConsulting
Expert 100+
P: 603
Fantastic, think i understand, but to double check, heres something that i hope helps ut get closer.

1 form with all buttons for stock items, a sub form with a reciept (as you click its description and quantity tally up as you go.

another subform on the main form with the balance, which updates after each selection.

so with this in mind i would like the following to occur.....

1. When subtotal is clicked, a form (over unclosed button form) opens. (easy enough to do)

2. This form has the balance on one side (shown as a negative value which i guess would be achieve by subtracting its value twice from itself, but not sure how to do this)

3. The user selects the numbers which make the amount tendered, and clicks "tender"

4. Another form opens, showing the change due, and a button which will save and close the transaction
I think the form open in your case would pull your amount off the subform?

so if you're opening the 2nd form from a button on your main form..you need to change the "openargs" in the form open statement to reference that field on the subform

me.subformname.form.fieldname where your names apply

J
May 11 '07 #8

P: 32
the actual form holding the information is a subform, but its as an expression, so its name is expr1. I have tried this but no joy
May 11 '07 #9

JConsulting
Expert 100+
P: 603
the actual form holding the information is a subform, but its as an expression, so its name is expr1. I have tried this but no joy
show me what you've tried....that way I can help you.
J
May 11 '07 #10

P: 32
ok here goes.

all buttons that create transactions are on 1 page "frm_add_transaction", nothing subbed with regards to buttons.

A sub form "fsub_reciept" is on "frm_add_transaction".

"fsub_subtotal" is a subform also on "frm_add_transaction".

"fsub_subtotal" is made using the following query

tbl_transaction_product.product_id, tbl_transaction_product.quantity (COUNT), tbl_products.value (COUNT), AS expr1 (Sum([Quantity]*[Value])

-----------------------------------------------------------------------------------------------------------------

There is a page of buttons labelled 0,1,2,3,4,5,6,7,8,9. All code has been inplimented, except for the module for the calculator page (as i dont really understand what you asking.


would it be easier if i emailed the db to you? its in 07 format
May 11 '07 #11

JConsulting
Expert 100+
P: 603
ok here goes.

all buttons that create transactions are on 1 page "frm_add_transaction", nothing subbed with regards to buttons.

A sub form "fsub_reciept" is on "frm_add_transaction".

"fsub_subtotal" is a subform also on "frm_add_transaction".

"fsub_subtotal" is made using the following query

tbl_transaction_product.product_id, tbl_transaction_product.quantity (COUNT), tbl_products.value (COUNT), AS expr1 (Sum([Quantity]*[Value])

-----------------------------------------------------------------------------------------------------------------

There is a page of buttons labelled 0,1,2,3,4,5,6,7,8,9. All code has been inplimented, except for the module for the calculator page (as i dont really understand what you asking.


would it be easier if i emailed the db to you? its in 07 format
I wouldn't have any way of opening an 07 database...however, to clarify what I am asking.

we're transferring the balance from one form to another. Now you may have already done that?? the openargs option in the open form command is what I was using for that.

When the "0-9" form opens...I was using that to set the value of the balance. Then, when I entered the numbers and clicked the button, it would subtract the amount entered from the amount in that balance field, thus producing the difference.

Are you able to use any of the code samples I provided?
J
May 11 '07 #12

P: 32
it wont let me past the me.mybalance. maybe becuase this is an expression?

I have converted the file to access 03 and stripped it down.



im sorry if im a bit testing, but im very new to this
May 11 '07 #13

P: 32
i have just had a look through the code, but it seems that anything with a ME in it, simply wont work.

I really do appreciate your help on this
May 11 '07 #14

JConsulting
Expert 100+
P: 603
i have just had a look through the code, but it seems that anything with a ME in it, simply wont work.

I really do appreciate your help on this
I'm working in Access 2000. I'll see if I can dig up some references about me. for your version. Not sure why it's doing that. I have 0 experience developing in Access 2007. I understand it's very different.

I'm also at work at the moment...coming out here when I get a few free minutes. Is there a way you can convert your DB down to access 2000?

J
May 11 '07 #15

MMcCarthy
Expert Mod 10K+
P: 14,534
Sorry to butt in. Something struck me when reading this. Are you sure the Me references are coded on the actual form they refer to? Otherwise you will have to use the full forms reference. Me simply stands for "this form".

Mary
May 12 '07 #16

P: 32
The code is exactly the same, it just seems to be cosmetic.

They can all be easily converted for backward compatibility
May 12 '07 #17

P: 32
Is there any chance we can start again with this as im getting quite confused.
May 12 '07 #18

MMcCarthy
Expert Mod 10K+
P: 14,534
Is there any chance we can start again with this as im getting quite confused.
OK post the code that is causing you the initial problem and say what the code is doing.
May 12 '07 #19

P: 32
Its all in the body of this post
May 12 '07 #20

MMcCarthy
Expert Mod 10K+
P: 14,534
Its all in the body of this post
You are the one who said you were confused and wanted to go back to the beginning. I'm only trying to assist.
May 12 '07 #21

JConsulting
Expert 100+
P: 603
i have just had a look through the code, but it seems that anything with a ME in it, simply wont work.

I really do appreciate your help on this

Hey,

I'm curious...inside your code (before we started)...how are controls (textboxes, listboxes, checkboxes) how are they referenced now?

I could not find any references for Access 2007 stating that that particular method of referring to a form is no longer available.

I Want to help you get this going...so can we recap?

1. You have a main form..
2. You want another form to open when you click on a control
3. you want to be able to enter numbers (which display in a textbox) and this textbox is different than the one that displays the "balance"
4. you press a button and that number you entered is applied against the "balance" and the balance is adjusted, the form closes, and that value is returned to your main form.

Please run that down and let me know if it's correct, and what...if any code you have that's in place for it (working or not)
J
May 12 '07 #22

JConsulting
Expert 100+
P: 603
Is there any chance we can start again with this as im getting quite confused.
Attempting to attach a zip file.
Attached Files
File Type: zip Calculator.zip (27.4 KB, 257 views)
May 12 '07 #23

Post your reply

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