Only show checked box, dont leave empty space

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with 17 checkboxes (yes/no). On another form I only want to
see the checkboxes that have been checked (yes). This is easy, but the hard
part is to not leave empty spaces on the form that are where the checkbox
should be. I have seen other posts about right alignment, but any other
suggestions or more detail on this technique would be a great help.
 
Ryan said:
I have a form with 17 checkboxes (yes/no). On another form I only want to
see the checkboxes that have been checked (yes). This is easy, but the hard
part is to not leave empty spaces on the form that are where the checkbox
should be. I have seen other posts about right alignment, but any other
suggestions or more detail on this technique would be a great help.


How is the check box's data getting to the second form? If
it's bound to a table/query that is set by the check boxes
in the first form, then you can use some code in the second
form's Current event.

To make the code much simpler, name the check boxes with a
constant prefix and a sequential number suffix (e.g. chk1,
chk2, ..., chk17). The code for this kind of arrangement
would be like this air code:

Const clngGap As Long =100 'twips
For k = 1 To 17
With Me("chk" & k)
If .Value = True Then
.Visible=True
.Top = clngGap + (k - 1) * (.Height + clngGap)
Else
.Visible = False
End If
End With
Next k
 
Haha, you have been answering another post of mine today concerning the same
subject. I see you code now and how it work, however, I have a problem.
This database is in use and very big already. Unfortunantly the fields all
have very differant names. Looking at your code this could be a big problem.
Correct me if Im wrong, but this will only work with a constant prefix and
sequential suffix?
 
I keep getting an error here

Else
.Visible = False
The error is
Run Time Error 438
Object doesnt support this property or method.
I changed all my field names to CHK1-CHK17 to accomidate your code. Any
suggestions?
 
The only way I can explain that error is if you are using
the word "field" too generically. A "field" is a column in
a table/query. The check boxes on the form are "controls".

You did not need to change the name of the fields, only the
control names were important to the code.
 
Do you have or know of any sample databases with this code? Im having
troulbe with applying it and I'm sure I'm just using it in the wrong spot or
in the wrong way. An example would be great if you know of any?

Marshall Barton said:
The only way I can explain that error is if you are using
the word "field" too generically. A "field" is a column in
a table/query. The check boxes on the form are "controls".

You did not need to change the name of the fields, only the
control names were important to the code.
--
Marsh
MVP [MS Access]


Ryan said:
I keep getting an error here

Else
.Visible = False
The error is
Run Time Error 438
Object doesnt support this property or method.
I changed all my field names to CHK1-CHK17 to accomidate your code. Any
suggestions?
 
Ryan said:
Do you have or know of any sample databases with this code? Im having
troulbe with applying it and I'm sure I'm just using it in the wrong spot or
in the wrong way. An example would be great if you know of any?


I have been posting example code, but as just became clear
in our other thread, we are trying to do the impossible
here. Let's drop this thread and confine the discussion to
the earlier thread where I think I posted a completely
different approach.
 
Back
Top