repeating code multiple ck box

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

Guest

I have a number of ck boxes on a form I want to do the following to...

Private Sub Form_Current()

If Me.CompleteCO = True Then
Me.ColorTarget.Visible = False
End If
If Me.CompleteCO = False Then
Me.ColorTarget.Visible = True
End If
End Sub

Is there a concise way to accomplish this?
Thanks!
(check box names)
CompleteDB
CompleteP
CompleteDS
CompleteB
CompleteS
(Text Box I want to change visiblity on)
DBTarget
PTarget
DSTarget
BTarget
STarget
 
I have a number of ck boxes on a form I want to do the following to...

Private Sub Form_Current()

If Me.CompleteCO = True Then
Me.ColorTarget.Visible = False
End If
If Me.CompleteCO = False Then
Me.ColorTarget.Visible = True
End If
End Sub

Is there a concise way to accomplish this?
Thanks!
(check box names)
CompleteDB
CompleteP
CompleteDS
CompleteB
CompleteS
(Text Box I want to change visiblity on)
DBTarget
PTarget
DSTarget
BTarget
STarget

One way would be to create an array, or even a small table, with two
columns, one for the checkbox and one for the corresponding textbox. I
would suggest using a table especially if the list of controls might
be changing in the future, as it's easier to maintain. You'ld then use
code like

Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblVisibleToggle")
rs.MoveFirst
Do Until rs.EOF
Me!Controls(rs!Textboxname).Visible = Not rs.Checkboxname
rs.MoveNext
Loop


John W. Vinson[MVP]
 
I'm sorry I don't know what you mean. This is a small form that is based on
a small table of ck boxes for events. The target field is not on the table it
is unbound with a calculated date field. I want the date field to disappear
when the box is checked. and it works with the first line. I just don't know
how to add the additional lines. And I have four other tables that are the
same principle and so I thought maybe there was some other way to do the job.
Would you tell me how to combine the additional fields. Thank You!


Private Sub Form_Current()

If Me.CompleteCO = True Then
'Me.CompleteDB = True Then
'Me.CompleteP = True Then
'Me.CompleteDS = True Then
'Me.CompleteB = True Then
'Me.CompleteS = True Then

Me.ColorTarget.Visible = False
'Me.DBTarget.Visible = False
'Me.PTarget.Visible = False
'Me.DSTarget.Visible = False
'Me.BTarget.Visible = False
'Me.STarget.Visible = False
End If
If Me.CompleteCO = False Then
Me.ColorTarget.Visible = True

End If
End Sub
 

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

Back
Top