AutoFill Checkbox

B

Bob Quintal

What would be the code used to auto-check a checkbox when a date
is entered into a field?

Thanks,
Pam
Me.checkboxname = true

Put it in the date's afterupdate event.
If you also want to clear the checkbox if someone clears the date,
use this instead

If len(Me.datecontrolname & "" ) > 0 then
Me.checkboxname = True
Else
Me.checkboxname = False
end if

checkboxname and datecontrolname need to be adjusted to your reality.
 
P

Pam

What would be the code used to auto-check a checkbox when a date is entered
into a field?

Thanks,
Pam
 
B

Bob Quintal

Arvin and Bob, thank you for replying. I've tried both codes,
actually I already had a version of Bob's, and still can't get the
check box to have a check mark placed in it when the field is
double clicked. I thought this would be a simple one I could get
on my own. Do you have any ideas why this isn't working?
Thanks,
Pam

How do you enter a date into a field using a doubleclick?

Lemme guess... you have code in the doubleclick event of the date
textbox that sets the date to today?

Add the code there as well, because the afterupdate event is not
triggered when you populate a textbox programmatically.

If thats not the case, what is?



 
A

Arvin Meyer [MVP]

Pam said:
What would be the code used to auto-check a checkbox when a date is
entered into a field?

Sub txtDateField_AfterUpdate()
If Not IsNull(Me.txtDateField) Then
Me.chkWhatever = True
Else
Me.chkWhatever = False
End If
End Sub
 
P

Pam

Arvin and Bob, thank you for replying. I've tried both codes, actually I
already had a version of Bob's, and still can't get the check box to have a
check mark placed in it when the field is double clicked. I thought this
would be a simple one I could get on my own. Do you have any ideas why this
isn't working?
Thanks,
Pam
 
P

Pam

Bob - you saved the day!! I've switched that code so many different ways
thinking I knew what I was doing. And once again I've learned something new
from the experts- "because the afterupdate event is not
triggered when you populate a textbox programmatically."

By the way, "Lemme guess... you have code in the doubleclick event of the
date
textbox that sets the date to today?"
Yep. I've had to jump thru hoops to get these users to even enter the time
and date, let alone leaving them to enter it in a consistent format.

Thank you so much for the help and prompt reply (glad I didn't have to wait
'til Monday!!)
Pam
 
A

Arvin Meyer [MVP]

Hey Bob,

Your computer's clock is off. You answered a question asked at 4:33 at 4:33
and one at 4:56 with an answer at 4:15 (before it was even asked).

You may have the time zone wrong, but more likely the computer's time is
just wrong.
 
B

Bob Quintal

Hey Bob,

Your computer's clock is off. You answered a question asked at
4:33 at 4:33 and one at 4:56 with an answer at 4:15 (before it was
even asked).

You may have the time zone wrong, but more likely the computer's
time is just wrong.

Arvin, I just checked the computer's clock against
http://www.time.gov/timezone.cgi?Eastern/d/-5/java and it's only off
by 7 seconds. But I resynced it. now it's off <1 second.

Maybe my usenet provider mangled the header. They call themselves
TeraNews. they forgot the ble in the middle.
 
P

Pam

I'm sorry- can you explain what the BIG difference would be?
If you are double-clicking, why not just click once in the checkbox?
I have users (shop guys who hate paperwork or anything to do with any type
paperwork) who do bare minimum to get by. They forget to log off computer
when a job is complete. I want something so that when a form pops up when
they come back in Monday and whoever starts program will enter stop time for
the forgotten person and this time will be flagged as several days instead
of several hours. I want to make it a simple as possible.

Pam
 
P

Pam

Hi Arvin,

I appreciate you suggestions and your time in replying to my message.
Please note answers inline below:

May I suggest that you automatically shut down anyone who doesn't use the
program for 20 to 30 minutes?
This is a time tracking database for a repair shop. Sometimes the techs
will log on early in the a.m.and not log off until lunch, this can be as
much as 4-6 hours on one job.
or shut all Access programs down at a specific time
I thought about this also. Shut it down at 5:00 p.m. - they can often work
past 5:00. They can also be called out in the middle of the night for
emergency repairs.

Can't just kick them out, they may be in the middle of a job.

The way I have it setup may see elementary or not quite what a programmer
would do, but I've put a great deal of thought into how to automatically
trap "running time" and in every scenario there was a reason why it wouldn't
work.

If you have any other suggestions, I'm all ears! I've learned so much from
this newsgroup and I appreciate all the help, ideas, suggestions,
recommendations, etc. I can get.
Thanks,
Pam
 
A

Arvin Meyer [MVP]

The code for a double-click event on a text box would look something like:

Sub txtDateField_DblClick(Cancel As Integer)
Me.chkWhatever = True
End Sub

Remember, knowing when they started and when they finished will not give you
accurate times if the don't log out when they go home. Also, you take a
chance on corruption if users don't log out. I once had a user go home on a
Friday evening without logging out. When the painters cam in on Saturday,
they unplug the machine and corrupted the database.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
P

Pam

Arvin,

Thanks for the insight. I've already set the double-click event. I
recently ran a report for boss and was suprised at the times they forgot to
log off. That's why I wanted the check box to be automatically checked when
this particular form popped up. It will flag those who are not logging off.
I now have forms set to pop up when the program is shut down and when they
log on in the morning. Other than standing at the door as they leave and
reminding them, that's about all I can think to do.

You've been so helpful with this post, I wonder if you would mind looking at
another post I submitted yesterday on how to make a combo box selection
appear in the subform when another form opens. I can do cascading combo's
but am having trouble with this. If you care to help, it is "Open Form"
dated 9/24/07.
Thanks again for your help.
Pam
 

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

Top