Auto enter date in a table if Yes/No button is checked

G

Guest

Hello pros, I have a table with 3 fields [Address](text), [Sent](date),
[Yes/No](Yes/No)
(I am using access 2003) What's the easy way to automatically enter today's
date in the [Sent] field IF the Yes/No button is checked (If checked I want
the date if not, no date should be entered)?

Thank you,
Silvio
 
D

Douglas J Steele

In the Click event of the Yes/No box, put code like:

Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
End If

End Sub

If you want to clear the Sent field if the box gets unchecked, try:


Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
Else
Me!Sent = Null
End If

End Sub
 
G

Guest

Can this be handled at the table level or I need to use a form to run the
routine?

Douglas J Steele said:
In the Click event of the Yes/No box, put code like:

Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
End If

End Sub

If you want to clear the Sent field if the box gets unchecked, try:


Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
Else
Me!Sent = Null
End If

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Silvio said:
Hello pros, I have a table with 3 fields [Address](text), [Sent](date),
[Yes/No](Yes/No)
(I am using access 2003) What's the easy way to automatically enter today's
date in the [Sent] field IF the Yes/No button is checked (If checked I want
the date if not, no date should be entered)?

Thank you,
Silvio
 
D

Douglas J Steele

It must be done with a form.

Realistically, you don't need the Yes/No field in your table: whether or not
there's a value in the Sent field will give you the value for Yes/No!

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Silvio said:
Can this be handled at the table level or I need to use a form to run the
routine?

Douglas J Steele said:
In the Click event of the Yes/No box, put code like:

Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
End If

End Sub

If you want to clear the Sent field if the box gets unchecked, try:


Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
Else
Me!Sent = Null
End If

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Silvio said:
Hello pros, I have a table with 3 fields [Address](text), [Sent](date),
[Yes/No](Yes/No)
(I am using access 2003) What's the easy way to automatically enter today's
date in the [Sent] field IF the Yes/No button is checked (If checked I want
the date if not, no date should be entered)?

Thank you,
Silvio
 
G

Guest

Douglas thank you for your feedback, however, following your suggestion of
not have that field at table level and have it only at form level, this is
what’s happening: I have 10 records, and if I place a check mark on record
No.3 all the 10 records on my forms are acting the same meaning that they all
show the check mark and the same happen if I uncheck the box they all clear
out even though the actual date seem to be place correctly for the specific
raw only. What I am doing wrong?

Thank you,
Silvio


Douglas J Steele said:
It must be done with a form.

Realistically, you don't need the Yes/No field in your table: whether or not
there's a value in the Sent field will give you the value for Yes/No!

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Silvio said:
Can this be handled at the table level or I need to use a form to run the
routine?

Douglas J Steele said:
In the Click event of the Yes/No box, put code like:

Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
End If

End Sub

If you want to clear the Sent field if the box gets unchecked, try:


Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
Else
Me!Sent = Null
End If

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hello pros, I have a table with 3 fields [Address](text), [Sent](date),
[Yes/No](Yes/No)
(I am using access 2003) What's the easy way to automatically enter
today's
date in the [Sent] field IF the Yes/No button is checked (If checked I
want
the date if not, no date should be entered)?

Thank you,
Silvio
 
D

Douglas J. Steele

Unfortunately, you can't have unbound fields on continuous forms for that
exact reason.

What I typically do in situations like that is put the logic into a text
box's DoubleClick event. In other words:

Private Sub Sent_DoubleClick()

If IsNull(Me!Sent) = True Then
Me!Sent = Date()
Else
Me!Sent = Null
End If

End Sub


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Silvio said:
Douglas thank you for your feedback, however, following your suggestion of
not have that field at table level and have it only at form level, this is
what's happening: I have 10 records, and if I place a check mark on record
No.3 all the 10 records on my forms are acting the same meaning that they
all
show the check mark and the same happen if I uncheck the box they all
clear
out even though the actual date seem to be place correctly for the
specific
raw only. What I am doing wrong?

Thank you,
Silvio


Douglas J Steele said:
It must be done with a form.

Realistically, you don't need the Yes/No field in your table: whether or
not
there's a value in the Sent field will give you the value for Yes/No!

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Silvio said:
Can this be handled at the table level or I need to use a form to run
the
routine?

:

In the Click event of the Yes/No box, put code like:

Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
End If

End Sub

If you want to clear the Sent field if the box gets unchecked, try:


Private Sub Yes_No_Click()

If Me!Yes_No = True Then
Me!Sent = Date()
Else
Me!Sent = Null
End If

End Sub

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hello pros, I have a table with 3 fields [Address](text), [Sent](date),
[Yes/No](Yes/No)
(I am using access 2003) What's the easy way to automatically enter
today's
date in the [Sent] field IF the Yes/No button is checked (If
checked I
want
the date if not, no date should be entered)?

Thank you,
Silvio
 

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