Time & Date Code

W

WYTAC

Can someone tell me what code I need to use for for a "On Click" for
display of date and time in the form field. Thanks in advance.:cool:
 
C

ChrisO

G’day WYTAC and welcome to the site.

I’ll make four assumptions here…

The ‘Field’ you wish to click on is actually a Control.
The Control you wish to click on is a Text Box.
The format of the date and time does not matter.
You wish to display the date and time only when you click on the
Control.

Four assumptions is way too many but this would be about as simple as
it gets.


Code:
--------------------

Private Sub txtMyTextBox_Click()

Me.txtMyTextBox = Now()

End Sub

--------------------
If anyone of the four assumptions is incorrect please say so and we can
look at it further.

Regards,
Chris.
 
W

WYTAC

That is correct, Thanks Chris. Now, will the date and time remain
displayed when you tab on to the next form field or will it only
display when that particular control is clicked?
 
W

WYTAC

Ok that did not work! What I am trying to do is have the date and tim
show in a "Date & Time Form field" in each record when the field i
clicked and remain visible from record to record. I hope all that mad
sense.

I had the field in the table as a date and time field, but changed i
to a text field to try your suggestion.

I am sure it shows that I am a novice at this.:confused
 
W

WYTAC

Well Chris I guess I just don't get it. I tried the code you had i
your test properties, however, I just get an error message when I clic
on the field even though I did adjust my field name in the code
 
C

ChrisO

G’day WYTAC

Can you zip a small sample db and post it.

A97 or A2K please.

Regards,
Chris
 
C

ChrisO

See how this goes.

I took the opportunity to remove all spaces in the Table names, Tabl
Field names, Form names and Form Control names. Also applied a bit o
naming convention to the Form Control names i.e. txt for Text Boxes
cbo for Combo Boxes that sort of thing.

Hope that helps.

Regards

+----------------------------------------------------------------
| Attachment filename: keycontrol.zip
|Download attachment: http://www.MSAccessForum.com.com/forums/attachment.php?postid=151709
+----------------------------------------------------------------
 
W

WYTAC

Chris Thank you so much oh Access Guru!!! That is perfect. You hav
done in minutes what I have been working weeks on with trial an
"failure". I am forever indebted.

Ma
 
W

WYTAC

OK Chris, How in the world would one go about expanding the limt o
charactors use in a value list. I have an extensive name list but o
course the source property won't accept 1800 charactors in the list
 
C

ChrisO

D’day WYTAC

Well I think the quick answer is… you wouldn’t want to.

I doubt if I’ve ever gone past 31 items in a value list, days in month
and I didn’t know the limit.

Consider a value list of names of 1800 characters.
What happens when one of those names needs deleting or you need to ad
to the list?
You would have to go into design mode and change the list by hand.
But what would happen if the database were an mde file? You can’t g
into design mode so you can’t change the list by hand. You can chang
the list in VBA but how would you enter the name to delete or add?

The whole thing sounds like a can of worms to me.

The names should be in a separate table and the comdo box should b
based on that table. The combo box should be set limit to list and th
database administrator should have a form, that only they can get to
in order to make changes to the contents of the table.

Having said that I must admit that I have no idea how the database i
going to be used.

But it looks like you are just starting out on this one so I woul
suggest reading up on database structure or looking at the Northwin
Traders example database that comes with Access. In particular have
close look at the Relationships window under the Tools menu, it’s
good place to start.

So I would suggest not using a value list except if they contain
fixed set of constants like months of the year and the like.

Regards,
Chris
 
W

WYTAC

Hey Chris,

I figured out how to make it work. Instead of using the wizard I type
the code into a word document and then pasted it directly into the Ro
Source. Worked great. :
 
C

ChrisO

G’day WYTAC


Well… there are usually plenty of ways to do things, and it looks lik
you just found another ( :D ) , but there is usually only one correc
method for any given situation.

By the way, how much have you got in there now?

Regards,
Chris
 
W

WYTAC

I seem to have got it all in without the wizard. Perhaps the wizar
adds charactors that are not evident
 

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