dynamic form how?

D

Daniel M

I have a for with some check boxes to select different types of jobs. once i
click the next button on the form i would like to open another form with the
options for only the items selected on the first form.

I was thinking of creating a subform for each job option and then putting
them on the second form. then when i open it i can just change the visability
of each subform based on check boxes.

The problem is how do i dynamically build this form so that there are no
spaces where the hidden items are?

Any other approaches i can use? thanks.
 
J

Jeanette Cunningham

Hi Daniel,
if I am understanding your problem correctly,

You put a single subform control on the form.
You can load whichever form you want into the subform control after the user
makes their selection using the checkboxes.

Here is an idea for the code.
User clicks the next button and the code on the button is something like
this-->

Dim strSubformName as String

Select case Me.ChkBoxesTicked
Case "a"
strSubformName = "fsubOne"
Case "b"
strSubformName = "fsubTwo"
Case "cb"
strSubformName = "fsubThree"
Case else
End Select

DoCmd.OpenForm "FormName", OpenArgs:=strSubformName
'end code for button--------------

On the Load event for the form that is going to open put code something like
this-->
If Len(Me.OpenArgs & vbNullString) >0 Then
Me.NameOfSubformControl.SourceObject = Me.OpenArgs
End If



The code will put the correct subform on that form that opens.

Note: replace control names with the appropriate names for your database.
The above is untested air code, you will need to change it to fit your
database.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D

Daniel M

Let me clarify further.

Form1: job type select.
has checkboxes that lists types of jobs.

Form2: each job selected with have a series of options. Form2 should only
open the series of options for the jobs selected on Form1. Yes there can be 1
or all checkboxes checked.

ie: Form1
x data
x phone
x cable

Form2
Data: number of drops? ___
Data: Cable type? ___

Phone: number of drops? ___
Phone: single or dual plates? ___

Cable: number of drops? ___

etc.

I dont want to have a single form that shows all the options because it can
get quite long. these are just a few of the examples. I also dont want to put
everything on one and only visible=true the ones selected because it will
leave blank spaces on the form.

Hope this clears up the idea i'm going for. I'm just starting this so i am
open to all options at this point. i'm just trying to figure out how to
attack it before i start. thanks.
 
J

Jeanette Cunningham

You can put one control on top of another control and make sure that only
one of them is visible at any time. You can also use code to move controls
up, down, left or right.

You could have hidden controls down the bottom of the form and when you want
them visible you can also move then where you want them, when they are
hidden move them back to their hiding place.

Use the Left and Top properties of controls to move them.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D

Daniel M

Ok i understand the concept but how would i implement it? I mean would i need
a case for all possible combinations checked to move the controls?
 
J

Jeanette Cunningham

Depending on what needs to be hidden and when, you could well need a whole
string of cases in a select case statement.
I have done this myself on occasions.
Sometimes I have used a constant as the usual top and another one for the
usual left for a control.
Then I can adjust the position by adding the amount to move ( - for a
negative move).

Me.Left = (lngcLeft & 2.5) * 567

567 is the conversion from cm to twips I use in Oz.
You may have a different one for inches to twips.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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

Top