On Click = now

18 views
Skip to first unread message

songr...@gmail.com

unread,
Nov 13, 2014, 3:02:44 PM11/13/14
to
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

John W. Vinson

unread,
Nov 13, 2014, 5:42:32 PM11/13/14
to
On Thu, 13 Nov 2014 12:02:42 -0800 (PST), songr...@gmail.com wrote:

>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

songr...@gmail.com

unread,
Nov 13, 2014, 10:44:19 PM11/13/14
to
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!

John W. Vinson

unread,
Nov 14, 2014, 6:05:11 PM11/14/14
to
On Thu, 13 Nov 2014 19:44:18 -0800 (PST), songr...@gmail.com wrote:

>On Thursday, 13 November 2014 15:02:44 UTC-5, songr...@gmail.com wrote:
>> 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!

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.

songr...@gmail.com

unread,
Nov 18, 2014, 6:31:03 PM11/18/14
to
On Thursday, 13 November 2014 15:02:44 UTC-5, songr...@gmail.com wrote:
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

John W. Vinson

unread,
Nov 18, 2014, 8:36:55 PM11/18/14
to
On Tue, 18 Nov 2014 15:31:01 -0800 (PST), songr...@gmail.com wrote:

>On Thursday, 13 November 2014 15:02:44 UTC-5, songr...@gmail.com wrote:
>> 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?

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.
\--

Gene Wirchenko

unread,
Nov 19, 2014, 12:43:08 PM11/19/14
to
On Tue, 18 Nov 2014 18:36:52 -0700, John W. Vinson
<jvinson@STOP_SPAM.WysardOfInfo.com> wrote:

[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
Reply all
Reply to author
Forward
0 new messages