 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 12th, 2004, 03:29 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Option Group Procedures
Hi,
I need to attach code to 2 option groups on a form. The first option group controls these 2 conditions: the other control group is enabled or not and asigns values to three fields in the form.
In one case, the second option group is enabled and the values in the three fields depend on the choice of this option group, and in the other case, the second group is disabled, and the values to the fields is set to 0.
The second option group asigns a value to fields by a formula ( different formula in each case ) and sets visibility of each field.
What would the structure of code have to look like to acheive this?
Thanks!
Cheers!
Mr.Crud
|
|

February 12th, 2004, 03:46 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Your ultimate goal is a little confusing but it sounds like you need to insert code into the after_update() event of each option box...if you can be a bit more specific as to your ultimate goal I may be able to assist you a little better
John
|
|

February 12th, 2004, 03:56 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
Thanks for the reply. This is for a POS system. Depending where we ship our orders, different taxations apply. In all, there are four different taxation scenarios which are:
Canada/Quebec --------> GST and QST apply
Canada/Maritimes------> HST applies
Canada/Rest of Canada-> GST only applies
USA-------------------> No tax applies
So far, i've seperated these four choices into 2 option groups, but i guess it would also be possible to combine them into one option group.
Is this clear enough, or you need more???
Cheers!
Mr.Crud
|
|

February 12th, 2004, 04:18 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
also, i forgot to mention that by default, the selections should be Canada/Quebec and calculate the taxes accordingly. So i think this poses a problem with using the AfterUpdate event, since when in the default region, no update is done to the options boxes
Mr.Crud
|
|

February 12th, 2004, 06:37 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In stead of an option box you may want to try a combo list. Set up a table with three columns,
1. primary key
2. location
3. tax rate
When configuring the combo box (values received by the tax table)on the form, bind the third value (tax rate) to the table underlying the order form. This will allow you to perform the necessary calculation by referencing the control name for the combo box. Does this help??
John
|
|

February 12th, 2004, 06:38 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Alrighty, i think i got it....
here's my code, in case someone else is looking for a solution to a similar problem. Frame60 and Frame67 represent my option groups
-----------------------------------------------------------------
Private Sub Frame60_AfterUpdate()
If Me!Frame60 = "1" Then
OptionQc.Enabled = True
OptionMaritime.Enabled = True
OptionCan.Enabled = True
ElseIf Me!Frame60 = "2" Then
OptionQc.Enabled = False
OptionMaritime.Enabled = False
OptionCan.Enabled = False
Me!Frame67 = "4"
TextTPS.Visible = False
TextTVQ.Visible = False
TextTVH.Visible = False
End If
End Sub
Private Sub Frame67_AfterUpdate()
If Me!Frame67 = "1" Then
TextTPS.Visible = True
TextTVQ.Visible = True
TextTVH.Visible = False
TextTPS.Value = Me!Text30 * 0.07
TextTVQ.Value = (Me!Text30 * 1.07) * 0.075
TextTVH.Value = 0
ElseIf Me!Frame67 = "2" Then
TextTPS.Visible = True
TextTVQ.Visible = False
TextTVH.Visible = False
ElseIf Me!Frame67 = "3" Then
TextTPS.Visible = False
TextTVQ.Visible = False
TextTVH.Visible = True
End If
End Sub
-------------------------------------------------------------------
Cheers!
Mr.Crud
|
|

February 12th, 2004, 06:40 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
AHHHH,
Now I see what you are trying to do...I thought it was merely for calculation purposes
John
|
|

February 12th, 2004, 06:45 PM
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I needed a graphical interface for my sales staff with default values, and of course, being a sales staff, i needed to make this pretty idiot-proof...
anyhoo, thanks for the replies!
Cheers!
Mr.Crud
|
|
 |