How do I update date value with the click of a button?

P

PDcrazy

I have created a form to be used in a police dispatch. I am trying to use
button commands to displace current date & time. EX: call received time,
dispatched time, arrived time and call completed time.

I am using text boxes to hold the data, formatted date/time. Should I be
using a different type field to hold data, or do I just not have code right.
There is nothing displaying in my field.

Thanks for any response,
PDcrazy
 
R

ruralguy via AccessMonster.com

What code do you have behind your CommandButtons?
I have created a form to be used in a police dispatch. I am trying to use
button commands to displace current date & time. EX: call received time,
dispatched time, arrived time and call completed time.

I am using text boxes to hold the data, formatted date/time. Should I be
using a different type field to hold data, or do I just not have code right.
There is nothing displaying in my field.

Thanks for any response,
PDcrazy
 
M

Marshall Barton

PDcrazy said:
I have created a form to be used in a police dispatch. I am trying to use
button commands to displace current date & time. EX: call received time,
dispatched time, arrived time and call completed time.

I am using text boxes to hold the data, formatted date/time. Should I be
using a different type field to hold data, or do I just not have code right.
There is nothing displaying in my field.


Either you have the code wrong, in the wrong place or it's
putting the date in an inappropriate location.

I could probably be more specific if you would post a
Copy/Paste of the button's Click event procedure along with
the name of the text box.

What you want is pretty simple and the Click event procedure
should need no more than one line of code like:

Me.thetextbox = Now
 
P

PDcrazy

Marshall Barton said:
Either you have the code wrong, in the wrong place or it's
putting the date in an inappropriate location.

I could probably be more specific if you would post a
Copy/Paste of the button's Click event procedure along with
the name of the text box.

What you want is pretty simple and the Click event procedure
should need no more than one line of code like:

Me.thetextbox = Now

The textbox name is "RECEIVED", and the code I've used is as follows:

Private Sub Rec_DT_Click()
Me.RECEIVED = Now()
End Sub

PDcrazy
 
M

Marshall Barton

PDcrazy said:
The textbox name is "RECEIVED", and the code I've used is as follows:

Private Sub Rec_DT_Click()
Me.RECEIVED = Now()
End Sub


Either that is not a Copy/Paste of your actual code or your
VBA editor installation is messed up.

Assuming you didn't make any other mistakes when you retyped
that code, the only things I can think of is that the
Received field in the table is not a Date **TYPE** field
(the format of the field is irrelevant).

Does the text box control have anything in its Format
property?
 
P

PDcrazy

Marshall Barton said:
Either that is not a Copy/Paste of your actual code or your
VBA editor installation is messed up.

Assuming you didn't make any other mistakes when you retyped
that code, the only things I can think of is that the
Received field in the table is not a Date **TYPE** field
(the format of the field is irrelevant).

Does the text box control have anything in its Format
property?

RE: The text box control. I've tried the same code with nothing in the
format, as well as the text box formatted as "General Date". I've even tried
changing the text box to a label.
 
B

benjaminkmartin

I used the code and it worked just fine for me. I just clicked on the
text box. I opened the text box's properties, went under "events",
and selected "on click". Copy and pasted the code. And added the
text box name. And it worked perfectly.
 
M

Marshall Barton

PDcrazy said:
RE: The text box control. I've tried the same code with nothing in the
format, as well as the text box formatted as "General Date". I've even tried
changing the text box to a label.


Changing the text box to a label is not a productive
exercise. Using a General Date format on the text box is
fine. The Format of the text box control is not the
important property. What you need to know is the ***TYPE***
of the **field** in the table.

Please double check the text box control's ControlSource to
make sure it contains the name of the correct field in the
form's recod source table/query. Also verify that the
record source table/query is updatable.

I really should see a Copy/Paste of the code so we can
verify that there are no typos in what you posted earlier.

As I said before, what you are trying to do is very simple,
so any problem must be coming from something other than just
assigning Now to a bound text box control. We need to hunt
around to find out what that something else could be.
 

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