How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask Richard Your Own Question

Richard
Richard, Software Specialist
Category: Microsoft Office
Satisfied Customers: 16836
Experience:  Over 15 year experience resolving Microsoft Office Issues
Type Your Microsoft Office Question Here...
Richard is online now
A new question is answered every 9 seconds

Hi experts, Have a simple problem that I lack the knowledge

Resolved Question:

Hi experts,

Have a simple problem that I lack the knowledge to complete.
I am trying to code a form to record current time in a field when a button is pressed on the form.

i.e. I have a vehicle dispatched time field, and I want the database to record the time when the button is pressed,

Any assistance very welcome,

Thanks,

Bryan. XXX@XXXXXX.XXX
Submitted: 2 years ago.
Category: Microsoft Office
Expert:  Richard replied 2 years ago.

Professional Help :

Hi there

Professional Help :

if it is sql or access, just put in as the default value

Professional Help :

=now()

Professional Help :

that will do it

Professional Help :

if you have difficulties, please let me know

Customer:

Thanks,

Professional Help :

your welcome, if it worked please remember to click accept

Customer:

So let me explain, I have a form which captures EMS vehicle dispatch data, the field I am trying to populate with the time is Call Details.Vehicle1 dispatch time, I am trying to get the time into that field on click from a button on the form, however, =now() doesnt work as it is formatted for time, not long date.

Customer:

Also am unsure of the query builder syntax to tell it to populate the other field with the time, once clicked

Professional Help :

what is it? MS SQL, ACCESS? .NET?

Professional Help :

once i know I can give you the correct syntax

Customer:

Access 2010

Professional Help :

ok, go to the field in form design

Professional Help :

right click and choose properties

Customer:

There

Professional Help :

ok look for default value

Professional Help :

in it type

Professional Help :

=now()

Professional Help :

and click out of it and test

Customer:

Ok, thanks, XXXXX XXXXX but remember, I need them to click a button to set the time, got pretty serious legal requirement as it is the recorded time for ambulance dispatch, there will be a lag between them starting capturing call data, and dispatching the ambulance, hence the requirement to trigger an event based on button click

Professional Help :

ok, then on the button event do this

Professional Help :

pretend the name of the field that holds the date it DATEFIELD

Professional Help :

then

Professional Help :

the onclick event of the button has this

Professional Help :

me.DATEFIELD.value = now()

Professional Help :

then when they click the button it would put it in the field

Customer:

Awesome, checking, thanks

Customer:

Do i need the table name or just the field name?

Professional Help :

just firld

Professional Help :

sorry not field

Professional Help :

control

Professional Help :

the name of the text box on your form that will hold the value

Customer:

Ok, sorry for being dumb, been years since I did this. Text box control is Vehicle 1 dispatch time, get an error when I enter me.Vehicle 1 dispatch time.value = now()

Professional Help :

no spaces

Customer:

Ah! do I need to rename the field in the table to kill out the spaces first?

Professional Help :

no, just name the control without spaces

Customer:

Ok, error now is it cant find macro called ME

Professional Help :

?

Professional Help :

did you do

Professional Help :

me.control.value = now()

Professional Help :

in the onclick event of the button?

Customer:

Yep,

Professional Help :

can you copy and paste it all here, including the sub name

Customer:

Exact text in the onclick event is: "me.Vehicle1dispatchtime.value = now()

Professional Help :

when you type me.

Professional Help :

do you see a list of controls?

Customer:

Starting over, 1 sec

Professional Help :

no problem

Customer:

Ok, when I do it in the expression builder I see it breakdown the command correctly, but now has different error.

Professional Help :

are you doing this in the onclick event of the button?

Professional Help :

let me make an example for you and send it

Customer:

Ok, thanks. I've done it both in the onclick box and also in the event builder, same result, I know Im being stupid, just cant remember how to!

Professional Help :

download this

Professional Help :

http://wikisend.com/download/128602/Database8.accdb

Professional Help :

look at form1

Professional Help :

and youll see how I have done it

Professional Help :

let me know if it still doesnt work for you please

Customer:

Thanks will check now

Customer:

I will do, Thanks for your help

Customer:

Got compile error: Method or data member not found.

Customer:

Am gonna take the spaces out of the field name and see if that works

Professional Help :

ok... but should matter

Professional Help :

just the control name is important

Customer:

OK, still no luck, matches your's exactly, with control name set right, Compile error: Method or data member not found

Professional Help :

can you upload the DB?

Professional Help :

go to www.wikisend.com

Professional Help :

give me the download link and I will do it for you

Professional Help :

how did you go with this Bryan?

Customer:

Uploaded database to link here: http://wikisend.com/download/408932/Emer-G-Med Project.accdb Table being populated is Call Details, Form in question is also Call details. You will see an unmarked button on top of the Time1 field (renamed to rule out a syntax error) if you could be so kind as to show me how you would populate the Time1 field on click I'd be very grateful

Professional Help :

ok, found the problem, you had the wrong name

Professional Help :

put this in the buttons onclick and replace the other code you did

Professional Help :

Me.Vehicle_1_dispatch_time.Value = Now()

Professional Help :

that works

Professional Help :

let me know how it goes please

Customer:

Brilliant, thanks a lot!!

Richard, Software Specialist
Category: Microsoft Office
Satisfied Customers: 16836
Experience: Over 15 year experience resolving Microsoft Office Issues
Richard and 2 other Microsoft Office Specialists are ready to help you

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
< Last | Next >
  • My Expert answered my question promptly and he resolved the issue totally. This is a great service. I am so glad I found it I will definitely use the service again if needed. One Happy Customer New York
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
 
 
 

Meet The Experts:

 
 
 
  • jstinehelfer

    Information Systems Manager

    Satisfied Customers:

    36
    A+ Comptia Certified computer repair
< Last | Next >
  • http://ww2.justanswer.com/uploads/JS/jstinehelfer/2012-6-6_215146_Pictureofme1.64x64.png jstinehelfer's Avatar

    jstinehelfer

    Information Systems Manager

    Satisfied Customers:

    36
    A+ Comptia Certified computer repair
  • http://ww2.justanswer.com/uploads/JA/JasonJames122/2011-12-16_135647_jasonjamesheadshotweb.64x64.jpg JasonJames122's Avatar

    JasonJames122

    Computer Enthusiast

    Satisfied Customers:

    0
    I manage all information systems (network of Windows PC's and servers with Microsoft Office products) for a small business
  • http://ww2.justanswer.com/uploads/JE/jessmagz/2012-6-6_18129_jm.64x64.jpg Jess M.'s Avatar

    Jess M.

    Computer Support Specialist

    Satisfied Customers:

    301
    Computer Software Specialist for more than 10 years
  • http://ww2.justanswer.com/uploads/CH/chutz747/2011-11-6_14231_me.64x64.jpg The-PC-Guy's Avatar

    The-PC-Guy

    Computer Manager

    Satisfied Customers:

    274
    20 years experience providing remote computer support
  • http://ww2.justanswer.com/uploads/SP/spherrod/2012-6-6_174244_1000852.64x64.JPG Steve Herrod's Avatar

    Steve Herrod

    Computer Support Specialist

    Satisfied Customers:

    125
    Trained in Microsoft Office from 2000 through to latest version 2010.
  • http://ww2.justanswer.com/uploads/SE/Seashore2011/2011-12-6_33418_111205223015.64x64.jpg Chris L.'s Avatar

    Chris L.

    Support Specialist

    Satisfied Customers:

    124
    Certified Expert with over 10 years experience.
  • http://ww2.justanswer.com/uploads/KR/krkljatorm/2012-6-24_153417_ITMiro.64x64.jpg IT Miro's Avatar

    IT Miro

    Computer Scientist

    Satisfied Customers:

    97
    Bachelor's Degree in Information Technology, Microsoft Certified Professional