Wrox Programmer Forums
|
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
 
Old February 12th, 2004, 03:29 PM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old February 12th, 2004, 03:46 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old February 12th, 2004, 03:56 PM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old February 12th, 2004, 04:18 PM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old February 12th, 2004, 06:37 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old February 12th, 2004, 06:38 PM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old February 12th, 2004, 06:40 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

AHHHH,

Now I see what you are trying to do...I thought it was merely for calculation purposes

John

 
Old February 12th, 2004, 06:45 PM
Registered User
 
Join Date: Feb 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Check Boxes/Option buttons/Option Group hewstone999 Access VBA 1 March 14th, 2008 07:25 AM
Option Group Variables (from Form to Module) emanuele.musa VB How-To 1 July 20th, 2007 03:58 PM
Hide Subform Using Option Group martinaccess Access 1 October 3rd, 2004 10:48 AM
Option group vnadig Access 6 September 8th, 2004 02:53 PM
How to deselect "Option Group" box? reindeerw Access 6 May 11th, 2004 06:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.