If chkbox <> null then...

michaeljohannes

Registered User.
Local time
Today, 14:40
Joined
May 3, 2007
Messages
67
Hello,

Can anyone suggest a possible solution for the following problem?

I have a simple popup form that has a checklist of events the my company wants to keep track of. Basically, I have 5 check boxes. Next to each of these check boxes I have a date column. ie checkbox1 represents (Did client x call back?) If a user clicks the checkbox, a date column (checkbox1date) becomes visible.

Put more simply (for my sake!)

If checkbox1 <> null then checkbox1date = visible

The problem is that if I use the trick of making the checkbox1date control on the form "Not visible" and use the simple script as part of the OnClick event of the checkbox1:

Code:
checkbox1date.visible = Not checkbox1date.visible

... the checkbox1date control will not appear (not visible) the next time the form is loaded.

I apologize if that's confusing... I don't think this is a tough problem but need an expert's advice.

This is what I have so far...

Code:
Private Sub Form_Current()

cbdate = Val(checkbox1.Value)

If cbdate <> Null Then
    checkbox1date.Visible = True
Else
    checkbox1date.Visible = False
End If

End Sub


Thanks for responding!
 
Hello:

A couple of questions:

Is the checkbox bound to a field in a table?

Also, the proper way to accomplish what your are doing is place the code in the AfterUpdate event of the checkbox control AND in FormCurrent event when you move to a new record. You need to test the value saved in the field.

Regards
Mark
 
You realize that you are suggesting having redundant data in your table right? You can accomplish what you need with just the date field since a date vs no date will satisfy your checkbox idea. I would also recommend using one of these calendars to enter the date.
 
Hello:

A couple of questions:

Is the checkbox bound to a field in a table?

Also, the proper way to accomplish what your are doing is place the code in the AfterUpdate event of the checkbox control AND in FormCurrent event when you move to a new record. You need to test the value saved in the field.

Regards
Mark

Hi Mark,

Thanks for the speedy reply. Yes it is bound to a table.... And I do realize it's redundant data (and it bugs me so!!) But it's what my boss wants...

I get the idea that if data<>null, then the same information is available to me (as a sort of developer or DBA). But to the average user in this company, they want the checkbox....

So, is there anything else I can do (other than adding the if statement to the afterupdate event)?

thanks!
mike
 
CheckBoxes are either True or False so if you call this SubRoutine from the
Current Event of the form as well as the Click event of the CheckBoxes, it should work.
Code:
Sub ShowDates()

   Me.CheckBox1Date.Visible = Me.CheckBox1
   Me.CheckBox2Date.Visible = Me.CheckBox2
   Me.CheckBox3Date.Visible = Me.CheckBox3
   Me.CheckBox4Date.Visible = Me.CheckBox4
   Me.CheckBox5Date.Visible = Me.CheckBox5


End Sub
...using your control names of course.
 
If cbdate <> Null Then ---- will ALWAYS return false. If you want to find out if something is null, you need to use the IsNull() function.

If IsNull(cbdate) Then

or since this is a date field, you can check it for a valid date:

If IsDate(cbdate) Then
 

Users who are viewing this thread

Back
Top Bottom