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

change the form based on options button

P: 23
Is there a way to change the appearance of my form based on which option button is selected? I am using a form to input data into a table of transactions. There are basically 3 types of transactions (the type of which I would specify with an options button) and, though they all share common fields, some entries do not require all of the fields to be populated. For these I'd like for some of the combo boxes (my form uses combo boxes exclusively for data input) to not be visible. Is this sort of thing feasible or would I be better off just using Tab Controls? (Though I don't really want to take that option). I am using Access 2003.
Oct 9 '07 #1
Share this Question
Share on Google+
4 Replies


nico5038
Expert 2.5K+
P: 3,072
You can use the AfterUpdate event of the Frame holding the options to code a SELECT CASE like:
Expand|Select|Wrap|Line Numbers
  1. SELECT CASE fraOptions
  2. Case 1
  3.    Me.cmb1.visible = true
  4.    Me.cmb2.visible = false
  5. Case 2
  6.    Me.cmb1.visible = false
  7.    Me.cmb2.visible = true
  8. end select
  9.  
This will require all the fields to be set to true or false !

The tab control can be used and the buttons can be hidden.
Then the fields can be placed on three tabs and the correct tab can be activeted in the same AfterUpdate event by using the fraOptions value like:
Expand|Select|Wrap|Line Numbers
  1. Me.tabctl1.Pages(fraOptions).setfocus
  2.  
Getting the idea ?

Nic;o)
Oct 9 '07 #2

P: 23
I'll have a look. Thanks. As a beginner, though, it may be a bit over my head.
Oct 10 '07 #3

nico5038
Expert 2.5K+
P: 3,072
Then I would probably just use a tabcontrol and place the "specific" values per page.
The code I posted needs to be placed in events for the form. Looks "freightning", but is rather "easy".
To start you could define a new button with the button wizard, e.g. for opening another form, then you can inspect the created code by Access by clicking on the [...] button after the Procedure for the OnClick event in the properties window.

Nic;o)
Oct 10 '07 #4

NeoPa
Expert Mod 15k+
P: 31,494
I'll have a look. Thanks. As a beginner, though, it may be a bit over my head.
Nico's first solution in post #2 (Select Case ...) should precisely meet your requirements. It looks complicated first time but give it a go. We can always help some more if you don't understand it all clearly first time through.
What it's basically doing is showing or hiding ALL of your variable fields (those which are sometimes shown but sometimes hidden) depending on the selection of your option buttons (The fraOptions control there is referring to the Frame that the radio buttons are in. It's value will always reflect which button is selected).
Oct 12 '07 #5

Post your reply

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