Value extract a value

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

Guest

I have a couple of issues:
1) I'm trying to get a checkbox to become checked if certain values are
entered. For instance, if my "date" text box has any value, I'd like the
checkbox to become checked. I'm assuming I will have to extract the value
from the field for the individual record, but I'm not sure how to do this.

2)Is there a good way to update this upon value changes? Right now I'm
setting this to update whenever the mouse is moved on the form.

Thanks!
 
Ok, I figured out the first part, to extract the value, I just typed
Me.Fieldname
Does anyone have any suggestions for the second part?
Thanks
 
I have a couple of issues:
1) I'm trying to get a checkbox to become checked if certain values are
entered. For instance, if my "date" text box has any value, I'd like the
checkbox to become checked. I'm assuming I will have to extract the value
from the field for the individual record, but I'm not sure how to do this.

2)Is there a good way to update this upon value changes? Right now I'm
setting this to update whenever the mouse is moved on the form.

Thanks!

The yes/no field should NOT be stored in any table, if its value in
fact depends on the date field.

Instead, just calculate it dynamically. For instance, on a Form or
Report you can have a checkbox control with a rowsource of

=Not IsNull([datefield])


John W. Vinson[MVP]
 
Andy,

If I understand what you want correctly, I would say you need to put
some code on the After Update event of the "date" textbox, something the
equivalent of this...
Me.NameOfYourCheckbox = Not IsNull(Me.NameOfYourDateTextbox)

It's a puzzle, though, what the purpose of this would be. I mean, if
the date box is empty, you can see that it's empty, without needing a
checkbox to tell you so? Or have I meesed the point?
 
Steve and John,
Thanks for your help. The purpose of the checkbox is to be checked if
multiple conditions apply. For one, the date box must have an entry, I also
have a "Stress" text box which, if left null or changed to "inbox", to allow
the checkbox to become checked, otherwise I need the checkbox to become
unchecked. In the end, I want to develop a filter that will only bring up
records that have the checkbox checked. I imagine I wil have to do this
through a series of if statements. Does that seem right?

Thanks Again
Andy
 
Steve and John,
Thanks for your help. The purpose of the checkbox is to be checked if
multiple conditions apply. For one, the date box must have an entry, I also
have a "Stress" text box which, if left null or changed to "inbox", to allow
the checkbox to become checked, otherwise I need the checkbox to become
unchecked. In the end, I want to develop a filter that will only bring up
records that have the checkbox checked. I imagine I wil have to do this
through a series of if statements. Does that seem right?

Yep. Sounds like you might want to write a custom VBA function which
goes through the logic tree; something like

Private Function ShowCheck(vDate As Variant, vStress As Variant,
<other possible arguments>) As Boolean
If IsNull(vDate) Then
<do something appropriate>
....
End Function

In the function you would set ShowCheck to True or False
appropriately. On the Form you'ld set a checkbox control's Control
Source to

=ShowCheck([txtDate], [txtStress], [ThisControl], [ThatControl])

to automatically display the appropriate check.

John W. Vinson[MVP]
 
Thanks a ton- you've been very helpful.
--andy

John Vinson said:
Steve and John,
Thanks for your help. The purpose of the checkbox is to be checked if
multiple conditions apply. For one, the date box must have an entry, I also
have a "Stress" text box which, if left null or changed to "inbox", to allow
the checkbox to become checked, otherwise I need the checkbox to become
unchecked. In the end, I want to develop a filter that will only bring up
records that have the checkbox checked. I imagine I wil have to do this
through a series of if statements. Does that seem right?

Yep. Sounds like you might want to write a custom VBA function which
goes through the logic tree; something like

Private Function ShowCheck(vDate As Variant, vStress As Variant,
<other possible arguments>) As Boolean
If IsNull(vDate) Then
<do something appropriate>
....
End Function

In the function you would set ShowCheck to True or False
appropriately. On the Form you'ld set a checkbox control's Control
Source to

=ShowCheck([txtDate], [txtStress], [ThisControl], [ThatControl])

to automatically display the appropriate check.

John W. Vinson[MVP]
 

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