473,508 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Recording the Time Automatically into a Table from a Form

3 New Member
Greetings,
I need to brush up on my somewhat rusty Access skills. The problem I face is a very elementary one but for the life of me I cannot figure out how to solve it.

A form in my database needs to record the time a user adds a record and update this in the relevant table. I have created a textbox in the form which is bound to the associated field in the table. This textbox is hidden the locked, so the user will not be able to see or use it.

I am trying to display the time in this textbox when a command button is clicked. Since this textbox is bound to the relevant field in the table, that updates when the textbox's value changes. My textbox is "EntryTime", my command button "Save". Here's the code I currently have:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Save_Click()
  2. EntryTime.Text = Time
  3. End Sub
  4.  
This gives me the error "Runtime error 2185: You can't reference a property or method for a control unless the control has the focus". I have tried different variations on my code, but cannot get past this error.

I would greatly appreciate it if someone can shed some light on this.

Thanks.
Mar 17 '07 #1
4 1994
MMcCarthy
14,534 Recognized Expert Moderator MVP
Greetings,
I need to brush up on my somewhat rusty Access skills. The problem I face is a very elementary one but for the life of me I cannot figure out how to solve it.

A form in my database needs to record the time a user adds a record and update this in the relevant table. I have created a textbox in the form which is bound to the associated field in the table. This textbox is hidden the locked, so the user will not be able to see or use it.

I am trying to display the time in this textbox when a command button is clicked. Since this textbox is bound to the relevant field in the table, that updates when the textbox's value changes. My textbox is "EntryTime", my command button "Save". Here's the code I currently have:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Save_Click()
  2. EntryTime.Text = Time
  3. End Sub
  4.  
This gives me the error "Runtime error 2185: You can't reference a property or method for a control unless the control has the focus". I have tried different variations on my code, but cannot get past this error.

I would greatly appreciate it if someone can shed some light on this.

Thanks.
You can't update a locked control.

Hide it and set enabled to false if you wish but don't lock it.

Mary
Mar 17 '07 #2
Smokey
3 New Member
You can't update a locked control.

Hide it and set enabled to false if you wish but don't lock it.

Mary
Thanks for the quick response. I tried unlocking the textbox but still get "Runtime error 2185: You can't reference a property or method for a control unless the control has the focus".

Thanks
Mar 17 '07 #3
Smokey
3 New Member
Thanks for the quick response. I tried unlocking the textbox but still get "Runtime error 2185: You can't reference a property or method for a control unless the control has the focus".

Thanks
Sorry, I forgot to add that I can change the value in textbox "EntryTime" with any of its own methods (LostFocus, etc.). Just can't seem to do it with any other control.
Mar 17 '07 #4
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Save_Click()
  2.  
  3.    Me!EntryTime.SetFocus
  4.    Me!EntryTime.Value = Time
  5.  
  6. End Sub
Mary
Mar 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2393
by: Manfred Schwab | last post by:
Recording messages and print statements in a textfile during program execution. Is there a similar command to redirect errormessages or print statements into a standart asciifile during...
2
2150
by: Steve Miller | last post by:
hello... i am a 'user' of access, meaning, i import excel files, join, and merge....that's about the extent of my expertise with ms-access. my boss wants me to create an access application that...
3
1296
by: Chris Thompson | last post by:
I have an Access 97 database to record the current location and status of files in our office. Each file has a record one field of which is it's current location. On the form for each record is a...
4
1538
by: Paul | last post by:
I have a form that is bound on a table. The form has a text box that has =Time() and an Add button. How can I update the time or make it the current time before adding a record on the table via...
4
2172
by: luscus | last post by:
I am trying to device a formula so that when i check of a yes/no box (done) it will automatically add the time in a field called "End Time" and at the same time stamp the amount of minutes...
1
1808
by: Sakharam Phapale | last post by:
Hi All, I am developing an application like sound recorder. While recording if there is a silence for more than given time (say 5 seconds), Recording should be paused.
1
2376
by: zhangzhi | last post by:
HI£º i have a big problem about audio recording. my boss wanna a application of audio monitor, and he wanna it will detect voice and start recording automatically, avoiding recording silences....
7
2933
by: Seymour | last post by:
I am trying to find a way to sign onto my Wall Street Journal account (http://online.wsj.com/public/us) and automatically download various financial pages on stocks and mutual funds that I am...
2
2181
by: PWS | last post by:
Hi all, I developed an online learning website where each student has his own username/password and they can view course materials and take tests online. I did that in PHP and PostgreSQL. ...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.