A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Forcing the Current Date into a Form Field when a Checkbox is Clic



 
 
Thread Tools Display Modes
  #21  
Old March 3rd, 2006, 03:23 PM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Forcing the Current Date into a Form Field when a Checkbox is

Do you have a control bound to the field? What is the name of the control?

I would try

Me.[Expiry Date] = Now()

Also, you do know that Now() will return the date AND the time? If you want
just the date then use

Me.[Expiry Date] = Date()


"SkyGuy" wrote in message
...
Ok...here's my current code, which is working (somewhat). I change
Terminated
from "No" to "Yes" and Expiry Date remains blank. But after after I move
to
the next/previous record, then go back to the record that I set Terminated
to
"Yes", the Expiry Date will display the current date.

Private Sub Terminated_Change()
If Me.Terminated = "-1" Then
Me![Expiry Date].Value = Now()
MsgBox "Yes, I work!", vbOKOnly, "Test"
Else
MsgBox "No, I don't work!", vbOKOnly, "Test"
End If

End Sub

"John Spencer" wrote:

Pardon me, but I think that the Row source being Yes; No might end up
being
True/False when you are testing the value.

Using your earlier test technique

Msgbox "The value is " & me.terminated

IF the message comes back
The value is -1 or The value is 0 then you probably are returning true
and
false.

If the message is
The value is blank then you know that somehow your combobox is not
retaining the value.

"SkyGuy" wrote in message
...
Yes Gina, the Terminated form field has a little arrow to select from a
list.
So it is a combo box. Sorry for the mix up in terminology...I'm new to
this.

Bob

"Gina Whipp" wrote:

Selection LIst? You mean it's NOT a combo box? Combo Box has a
little
arrow where you select from a list.


"SkyGuy" wrote in message
...
Bound Column: 1
Column Count: 1
Row Source: Yes;No
Row Source Type: Value List

I'm not sure what you mean by combo box. But on the form, Terminated
is
a
selection list w/either a value of No or Yes. So I guess the correct
answer
to your first question is 2 rows.

"Gina Whipp" wrote:

Okay but at least we now know the code is being read! Your combo
box,
is
that a single row not 2 row

1;Yes
2;No

and the bound column is 1?

Please look at the Property Window of Terminated, what you should
see
is
Column Count = 1 and Bound Column = 1 and Row Source = Yes;No and
Row
Source
Type = Value List.


"SkyGuy" wrote in message
...
Gina,

A pop-up msg appeared that said "No, I don't work!". That was
cool.
But
obviously I still have a problem.

Bob

"Gina Whipp" wrote:

Please try pasting the below code and then change the combo box.
Does
a
message come up?

If Me.Terminated = "Yes" Then
'Me.[Expiry Date] = Date
MsgBox "Yes, I work!", vbOkOnly, "Test"
Else
MsgBox "No, I don't work!", vbOkOnly, "Test"
End If


"SkyGuy" wrote in message
...
Gina,

I replied to your post but it looks like it didn't take. So
here's
another
post.
First of all...thanks for your help...but my Date field is
still
not
populating.

I'm using MS Access 2002.

In Design View, I right-clicked on the Terminated Field,
selected
Properties, then scrolled down to After Update and clicked on
the
drop-down
arrow. There was only one choice; [Event Procedure]. I
selected
this
then
clicked on the elipses button to the right. A windows opened
and
I
pasted
my
code just below the "Private Sub Terminated_AfterUpdate()" and
did a
save.

Here's a copy of my code:

Private Sub Terminated_AfterUpdate()

If Me.[Terminated] = "Yes" Then
Me.[Expiry Date] = Date
End If


End Sub

Thanks again,
Bob


"Gina Whipp" wrote:

My 2 cents worth...

You said you went to ' form's Terminated field in Design View
then
'
(you
just want to make sure it's not on the After Update of the
form
because
it
needs to be on the After Update of the control)

Okay not sure the code is in the correct place, so just check

1. Go to Design View on the form
2. Go click on you field ' Terminated ' and then right mouse
click
if
Properties Window for your field is not showing and select
Properties.
3. In the Properties Window for your field scroll down till
you
find
the
After Update Event and select ... Build Event
4. Place your code, close and save. Try it, if that does not
work
post
back.

If you have already done the above "NEVERMIND"

The () after Date sometime disappears on mine to, still does
wht
it's
suppose to.

Gina

choice Build Event"SkyGuy"

wrote
in
message
...
Ok Ed...I right-clicked on the form's Terminated field in
Design
View
then
choice Build Event. I then chose "After Update" from the
drop-down
list
in
Visual Basic. But when I do a save Visual Basic eliminates
the
()
after
=Date
and the solution does not work. What am I doing
wrong...thanks.

"Ed Robichaud" wrote:

OK, just change it to:

If Me.[Terminated] = "Yes" Then
Me.[Expiration Date] = Date()
End if


"SkyGuy" wrote in
message
...
I apologize Ed...Terminated is not a Checkbox. It's a
Selection
List
with
either a value of Yes or No. So if I select Yes in
Terminated
I
want
the
Experiation field to be populated with today's date.
Again,
sorry
for
the
initial misinformation.
Bob

"Ed Robichaud" wrote:

In the AfterUpdate event of your checkbox, put:

If Me.[Terminated] = -1 then
Me.[Expiration Date] = Date()
End if

-Ed



"SkyGuy" wrote in
message
news Hello,

I'm new to Access and not familiar with Events,
Procedures
or
Visual
Basic.

I have a form with a Date Field called "Expiration
Date".
In
the
same
form
I
have a Checkbox called "Terminated".

I'd like the current date to automatically populate
the
Expiration
Date
when
Terminated is checked.

Any help would be very much appreciated.

Thanks,
Bob























 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto fill a field every row? Brian Using Forms 1 August 1st, 2005 07:35 PM
Access Mail Merge to Word.doc files ? RNUSZ@OKDPS Setting Up & Running Reports 1 May 18th, 2005 06:31 PM
Requerying a pop up form to display in the main form Jennifer P Using Forms 13 April 5th, 2005 06:59 PM
Dates in a listbox connected to a form... RusCat Using Forms 13 November 25th, 2004 02:31 AM
How do I set up a report using dates as my report header? Robin Setting Up & Running Reports 16 November 13th, 2004 01:00 PM


All times are GMT +1. The time now is 07:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.