Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date in field on control button click 3

Status
Not open for further replies.

holle400

Programmer
Dec 17, 2003
16
NL
Hi,

Can anyone explain me how i can fillin a datestamp when i press a command button when using a form.

I'm trying for 3 days now with no luck.

Thanx instead

Ewald
 
In the command button code:

Me![fieldname] = Date()

or Me![fieldname] = Now() if you want to include time in the datestamp

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Assuming the field is called Datestamp
on the onclick event put
Datestamp = now()

Hope this helps
Hymn
 
This is interesting. Is it possible to do the same thing, but instead of a command button, could this date stamp be done by selecting from a combobox? If in the combobox I had the option of Closed, Opened, ReOpened, whichever is selected, a date stamp would be entered into that field?

I can assume this could be done with a radio button?
 
Thanx,

This works great. But how can i disable a pressed button?

Sorry? I never worked with VBA before and forms in access

Thanx.

Ewald

 
Do you mean once you press the button it becomes diasbled? So the user cannot change the time?

IN the code you already have, add this to the end:

Me![buttonname].enabled = False

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
When i edit the code and test it in de form, I get the following mesage;

You cannot disable a control element what is focussed

How can I solve this.

When some of the text is not clear, that is because i have to translate the message from dutch to english
 
holle,

You could have the button set focus to another control, the date text box for instance:

in the On Click property:

[DateTxtBoxHere].SetFocus

and then in the On Lost Focus property:

[ButtonNameHere].Enabled = False
 
Let me add to that:

In the On Lost Focus Property:

If Not IsNull([DateTxtBoxHere].Value) Then
[ButtonNameHere].Enabled = False
Else
End If

This way the button will only disable if there is a date in the datestamp text box.
 
great suggestion ancb! have a star!

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
I am still having a problem getting the date to show on the form. I no longer get errors and it is calculating, but nothing happens.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top