On Click = now

S

songruaning

Hi,

I'm workin on a Access form (2010), and I would like to do the following:

When a user clicks a specific fiel, the value =Now() will be entered; or when a user clicks a button besides a field (such as time now), the value =Now()will be entered.

Thanks!

Song
 
J

John W. Vinson

Hi,

I'm workin on a Access form ?2010?, and I would like to do the following:

When a user clicks a specific fiel, the value =Now() will be entered; or when a user clicks a button besides a field (such as time now), the value =Now()will be entered.

Thanks!

Song

Forms don't have Fields: Tables have Fields. A field may be displayed on a
form in a Textbox or other type of form controls.

Assuming that you mean a Control on a Form named txtTimeNow (which might or
might not be bound to a field in the form's recordsource query/table), you can
put code in the textbox's Click event:

Private Sub txtTimeNow_Click()
Me!txtTimeNow = Now
End Sub

The same code could be put in a button's click event.

For clicking the textbox I'd suggest using the DblClick event - click is too
hairtrigger, it can fire when you don't really want it!

Note my .sig - this forum was killed off by Microsoft years ago. Only a few
folks even ever look at it.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:

http://answers.microsoft.com/en-us/office/forum/access?tab=question&status=all
http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=accessdev
and see also http://www.utteraccess.com
 
S

songruaning

Hi,

I'm workin on a Access form (2010), and I would like to do the following:

When a user clicks a specific fiel, the value =Now() will be entered; or when a user clicks a button besides a field (such as time now), the value=Now()will be entered.

Thanks!

Song

Thanks, John. I did as instructed, but when I test the form, nothing happens.; either on click or double-click. What could possibly be wrong?

Thanks so much!
 
J

John W. Vinson

Thanks, John. I did as instructed, but when I test the form, nothing happens.; either on click or double-click. What could possibly be wrong?

Thanks so much!

Please post your actual code: I can't see it from here. Did you compile the
database after entering the code? If you have ANY compile errors, even in
different routines, the code may not work.

You may also want to create a free account at www.utteraccess.com and upload a
zipped copy of the database (stripped of any personal or confidential data); I
or one of the other volunteers will be glad to help.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:

http://answers.microsoft.com/en-us/office/forum/access?tab=question&status=all
http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=accessdev
and see also http://www.utteraccess.com
 
S

songruaning

Hi,

I'm workin on a Access form (2010), and I would like to do the following:

When a user clicks a specific fiel, the value =Now() will be entered; or when a user clicks a button besides a field (such as time now), the value=Now()will be entered.

Thanks!

Song

Hi John,

After some trail and fail, it actually works now. I have TWO other questionS:

1. How do I calculate the time in seconds between the stating and ending time?

2. I would like to interactive buttons on a form, such as on a list of choices, if a user clicks on choice, another box will appear beside the choice so the user can then enter the details?

Thanks very much!

Song
 
J

John W. Vinson

Hi John,

After some trail and fail, it actually works now. I have TWO other questionS:

1. How do I calculate the time in seconds between the stating and ending time?

DateDiff("s", [StartTime], [EndingTime])
2. I would like to interactive buttons on a form, such as on a list of choices, if a user clicks on choice, another box will appear beside the choice so the user can then enter the details?

I would not use that kind of interface. Command buttons require programming...
and when you add another choice or change the choice, you must change the
design of the form, revise your code, test your code, cuss and swear, fix your
code, test it again...

Instead I'd use a continuous Form with a combo box in one column to choose one
of the options, with a textbox next to it to enter the details. But since I
have no idea what kind of data you're entering or what sort of choices there
are, I really don't know. All I can suggest is that you look at the options in
my .sig and post your question in a working forum:
microsoft.public.access.formscoding has had FOUR MESSAGES in the past year,
all in this conversation. "It's DEAD, Jim!"

You can get lots more people (and lots more experience and expertise) in the
answers.microsoft.com or utteraccess.com web forums.
\--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:

http://answers.microsoft.com/en-us/office/forum/access?tab=question&status=all
http://social.msdn.microsoft.com/Forums/office/en-US/home?forum=accessdev
and see also http://www.utteraccess.com
 
G

Gene Wirchenko

On Tue, 18 Nov 2014 18:36:52 -0700, John W. Vinson

[snip]
microsoft.public.access.formscoding has had FOUR MESSAGES in the past year,
all in this conversation. "It's DEAD, Jim!"

17 plus this one. That does not count the two on November 19th
of last year.
You can get lots more people (and lots more experience and expertise) in the
answers.microsoft.com or utteraccess.com web forums.

Possibly, but Web forums are an awkwardness of their own.

Sincerely,

Gene Wirchenko
 

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