By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,224 Members | 1,103 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,224 IT Pros & Developers. It's quick & easy.

command button - save time to record in HTML page

P: 28
hi,

how do i setup a command button on a page form that when clicked, saves system time in a particular field of a table ?
Aug 21 '08 #1
Share this Question
Share on Google+
10 Replies


missinglinq
Expert 2.5K+
P: 3,532
For just time:
Expand|Select|Wrap|Line Numbers
  1. Private Sub GetTimeButton_Click()
  2.  Me.TimeField = Time
  3. End Sub
For Date and Time:
Expand|Select|Wrap|Line Numbers
  1. Private Sub GetTimeButton_Click()
  2.  Me.TimeField = Now
  3. End Sub
If you're going to be doing any comparing of times or calculating lapsed times, especially if the times may span different days, you should use the Now() function for Date/Time.

Linq ;0)>
Aug 21 '08 #2

P: 28
hi Linq,

i no that u are trying to help me..but i'm too new here......i tried usng ur code....but it does not work....req u to please give me the complete code which i could just copy and save in the VB script editor in MS Access

Table name: TimeTracker
page name: TimeTracker
Field name: EndTime
Command Button name: Command0

Take Care.....





For just time:
Expand|Select|Wrap|Line Numbers
  1. Private Sub GetTimeButton_Click()
  2.  Me.TimeField = Time
  3. End Sub
For Date and Time:
Expand|Select|Wrap|Line Numbers
  1. Private Sub GetTimeButton_Click()
  2.  Me.TimeField = Now
  3. End Sub
If you're going to be doing any comparing of times or calculating lapsed times, especially if the times may span different days, you should use the Now() function for Date/Time.

Linq ;0)>
Aug 22 '08 #3

missinglinq
Expert 2.5K+
P: 3,532
When people post code, especially when the Original Poster hasn't given the names of his/her controls, they use generic names, and you have to replace these names with the actual names of your controls. So GetTimeButton becomes Command0 and TimeField becomes EndTime.

For just time:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.  Me.EndTime = Time
  3. End Sub
For Date and Time:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.  Me.EndTime = Now
  3. End Sub
Also note, you should never leave a control with the name that Access gives it, like Command0. A month from now this name will mean absolutely nothing to you, or to anyone else who has to work with your code. You need to change it to something meaningful, like GetEndTimeButton.

Also, please note that the use of "texting" abbreviations is not allowed on these forums. Take the time to write complete words and complete sentences.

Linq ;0)>
Aug 22 '08 #4

P: 28
i tried using this aswell....but it does not work. Don't know what am i doing.


When people post code, especially when the Original Poster hasn't given the names of his/her controls, they use generic names, and you have to replace these names with the actual names of your controls. So GetTimeButton becomes Command0 and TimeField becomes EndTime.

For just time:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.  Me.EndTime = Time
  3. End Sub
For Date and Time:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2.  Me.EndTime = Now
  3. End Sub
Also note, you should never leave a control with the name that Access gives it, like Command0. A month from now this name will mean absolutely nothing to you, or to anyone else who has to work with your code. You need to change it to something meaningful, like GetEndTimeButton.

Also, please note that the use of "texting" abbreviations is not allowed on these forums. Take the time to write complete words and complete sentences.

Linq ;0)>
Aug 23 '08 #5

missinglinq
Expert 2.5K+
P: 3,532
What exactly does "does not work" mean? Nothing happens? You get error message? Please copy your exact code, sub header included, and post it here.

I just realized that you haven't said what version of Access you're running. It wouldn't be Access 2007, would it? The reason I ask, is that code does not run in 2007 unless your database resides in a folder that has been declared a “trusted” location.

To trust your folder, click:

Office Button (top left)
Access Options (bottom of dialog)
Trust Center (left)
Trust Center Settings (button)
Trusted Locations (left)
Add new location (button)


Linq ;0)>
Aug 23 '08 #6

P: 28
i'm using ms office xp professional....i used your code in the microsoft script editor of the HTML page i made though the ms access page wizard. it does not do anything, ie after keying the values i go to the table to check if the EndTime field has been added, but it's blank and there is no error.....do u feel like pulling your hair... :-)
Aug 24 '08 #7

missinglinq
Expert 2.5K+
P: 3,532
i used your code in the microsoft script editor of the HTML page i made though the ms access page wizard.
Sorry, you should have made that fact that you were talking about a web page clear in the beginning. This is really a whole subset of Access and I have absolutely no experience in this area! I'm going to edit your post title to make it clearer and perhaps someone who has experience in this area can help you!

Sorry!

Linq ;0)>
Aug 24 '08 #8

P: 28
thanx linq...you've been great help so far... :-)...no need to be sorry

Sorry, you should have made that fact that you were talking about a web page clear in the beginning. This is really a whole subset of Access and I have absolutely no experience in this area! I'm going to edit your post title to make it clearer and perhaps someone who has experience in this area can help you!

Sorry!

Linq ;0)>
Aug 26 '08 #9

Expert 100+
P: 374
is this page an HTML, clasic asp, or aspx page that you're trying to execute this button from?
Aug 26 '08 #10

P: 28
i don't kno the difference between them...but....i guess it's html...caus i am using the page wizard of MS access to make this page...and the command button is supposed to be on this page....

is this page an HTML, clasic asp, or aspx page that you're trying to execute this button from?
Aug 26 '08 #11

Post your reply

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