Question about Form Design/Layout

FoxRocks

Registered User.
Local time
Today, 23:43
Joined
Apr 24, 2012
Messages
35
Hello,

I am a brand new Access (2007) user and new to this form and I have a question regarding the design and layout of a form (the form was generated from a table). In this form I have a check box, that when selected, displays a text box. I've used the visibility feature on the text box, which by default is set to "no" and then I've got an "on click" event on the check box.
To give you an idea of the layout:
__________
Check box 1
Text box 1
Check box 2
Text box 2
Check box 3
Text box 3
Text box 4
Text box 5
Check box 4
Text box 6

So what I'm trying to make happen is that when the "check box 1" is not selected "check box 2" is right below it and not spaced further down as a result of "text box 1" being there. The reason for this is my form has a lot of check boxes with corresponding text boxes and I don't want the appearance of the form to look all weird with lots of spaces between the check boxes, especially because "check box 3" has multiple text boxes that are normally not visible below it.

Does that make sense? I design websites and I think of this as being sort of like a clamshell menu, where once you click on a parent menu item the rest of the list slides down to reveal all of the child submenu items.
I'm assume this is possible with Access as it seems to be a fairly good piece of software.

Anyways, thanks in advance for any help you can provide :)

~FOX~
 
Couple of suggestions for you.

1, position the textboxes to the right of the checkboxes, this way the checkboxes can be neatly stacked one on each other. Then when your check box on click event is triggered the relevant textbox(s) can be displayed

2, With the use of VBA you could shuffle the text and check boxes down the form. Do this with the controls 'top' parameter and edit it according to the height of it and the other text and check boxes.
 
Hi Isskint,

Thank you for the prompt reply!
Wouldn't editing the "top" parameter just make it overlap my text box? Or would those items move out of the way (down) when I select the check box, making the text box appear?
Sorry if I don't make sense, I'm super new to this program.

Thanks!!
~FOX~
 
It would all be in the code. As you make a textbox appear you would need move ALL the other controls below move down (and if you untick a checkbox everything needs to move back up).
Here is a little bit of code that does the trick :)

Checkboxes are named Check Box 1, Check Box 2 etc
Labels for check boxes are named chklabel1, chklabel2 etc
the textboxes are named text box 1, text box 2 etc
The lables for the textboxes are named txtlabel1, txtlabel2 etc

if you are not using a label on either control, just remove it

Option Compare Database
Private Sub Check_box_1_AfterUpdate()
Call ExpandDisplay([Check box 1], 1)
End Sub
Private Sub Check_box_2_AfterUpdate()
Call ExpandDisplay([Check box 2], 2)
End Sub
Private Sub Check_box_3_AfterUpdate()
Call ExpandDisplay([Check box 3], 3)
End Sub
Private Sub Check_box_4_AfterUpdate()
Call ExpandDisplay([Check box 4], 4)
End Sub
Sub ExpandDisplay(ExpDown As Boolean, CallLevel As Integer)
Dim BxWdthConst As Integer ' variable to hold the distance (in twips) to move controls
If ExpDown Then
BxWdthConst = 555 ' move down 555 twips
Else
BxWdthConst = -555 ' move up 555 twips
End If
'You would need to play around with the twip measurement to allow the appearance to be pleasing to the eye
'and to fit the form and other controls
Select Case CallLevel
Case 1
[text box 1].Visible = ExpDown
[Check box 2].Top = [Check box 2].Top + BxWdthConst
[ChkLabel2].Top = [ChkLabel2].Top + BxWdthConst
[Check box 3].Top = [Check box 3].Top + BxWdthConst
[ChkLabel3].Top = [ChkLabel3].Top + BxWdthConst
[Check box 4].Top = [Check box 4].Top + BxWdthConst
[ChkLabel4].Top = [ChkLabel4].Top + BxWdthConst
Case 2
[text box 2].Visible = ExpDown
[Check box 3].Top = [Check box 3].Top + BxWdthConst
[ChkLabel3].Top = [ChkLabel3].Top + BxWdthConst
[Check box 4].Top = [Check box 4].Top + BxWdthConst
[ChkLabel4].Top = [ChkLabel4].Top + BxWdthConst
Case 3
[text box 3].Visible = ExpDown
[text box 4].Visible = ExpDown
[text box 5].Visible = ExpDown
[Check box 4].Top = [Check box 4].Top + (BxWdthConst * 3)
[ChkLabel4].Top = [ChkLabel4].Top + (BxWdthConst * 3)
Case 4
[text box 6].Visible = ExpDown
End Select
[text box 2].Top = [Check box 2].Top + Abs(BxWdthConst)
[TxtLabel2].Top = [text box 2].Top
[text box 3].Top = [Check box 3].Top + Abs(BxWdthConst)
[TxtLabel3].Top = [text box 3].Top
[text box 4].Top = [Check box 3].Top + (Abs(BxWdthConst) * 2)
[TxtLabel4].Top = [text box 4].Top
[text box 5].Top = [Check box 3].Top + (Abs(BxWdthConst) * 3)
[TxtLabel5].Top = [text box 5].Top
[text box 6].Top = [Check box 4].Top + Abs(BxWdthConst)
[TxtLabel6].Top = [text box 6].Top
End Sub
 
Hi Pat,

Thanks for your interest in my problem. As of right now I don't really have a display "problem" but rather I was hoping to find a way to make something happen just from an idea in my head. I would be happy to post my "schema" if you tell me what that is and how to do it :)

I came up with this random idea after I learned how to make a text box appear or disappear based on if a check box was selected or not. So what I have is basically a question and answer type of scenario in my form. I have a check box that asks a question, if the answer is yes, they check the box and as a result I have follow up information that I need, which is what the text boxes are for. I've got multiple instances of this scenario throughout my form. What I was hoping to do is have all of my check boxes (yes or no questions) all nice and neatly arranged one on top of the other, but then if one was selected the rest would slide down and my text box (follow up questions) would be revealed.
I know I'm sort of repeating myself here from my first post, but I think this better explains what I'm trying to do. I haven't yet tried Isskint's solution yet to see if is in fact going to work for me or not, but based on what I've just said, do you still feel that it's not going to work? If that's the case, do you have any suggestions for me?

Thanks again for the help, I really appreciate it.

~FOX~
 
The code i have posted will do the job for you, however it's usefulness will come down to how you intend to deploy your database. If the database will be available only to people with MS Access on their PC's my solution will work, however if, as Pat pointed out, you are planning on using Access runtime (this converts your database into a self contained programme with all the MS Access codeing included) my solution will not work.
 
Thanks for the info guys, I'm not surprised to find out I have dreamed up something that will not work...I have a habit of doing that :)

So I haven't got to this point but now that you mention Access runtime...

Once my form is completed I want to be able to have someone use this form to populate my table, but without allowing them to be able to access or alter the design. Is that what Access Runtime is for?
 
Oooh, ok, that's cool. So it's the same idea as Adobe Acrobat and Adobe Reader. Interesting.
Because everyone here at work has Access installed than I can use the code that Isskint kindly supplied. Sweet :)

Thanks a lot for your help fellas!
~FOX~
 

Users who are viewing this thread

Back
Top Bottom