Solved

I'm trying to figure out how to update an access 2007 field on a from using a date and time picker similiar to the calendar picker in access

Posted on 2011-09-23
11
545 Views
Last Modified: 2012-05-12
I'm trying to figure out how to update an access 2007 field on a from using a date and time picker similiar to the calendar picker in access. I want to write the date and time to the field.
Time-Picker.docx
0
Comment
Question by:shieldsco
  • 5
  • 3
  • 3
11 Comments
 
LVL 12

Expert Comment

by:danishani
ID: 36590864
You can use the Date and Time Picker ActiveX control for this, set the Format on 2 dtp-Time.

See attached picture.
use TimePicker
Hope this helps,
Daniel
0
 
LVL 84
ID: 36591953
Was there some reason you closed out your identical question here: http://www.experts-exchange.com/Database/Miscellaneous/Q_27322292.html. Just curious, as the comment from Peter was a link to a very nice Date and Time picker that is built using native Access objects.

The use of ActiveX controls in Access is spotty, at best. The control suggested here was never intended to be used in Access, and while it works in many Access installations, it is not guaranteed to run in all of them.  I have had troubles with that specific control (the DTPicker control) in Access 2003 and 2007, but only on certain machines.

Note also that Access 2007/2010 has a builtin DatePicker, but it doesn't have anything for Time.



0
 

Author Comment

by:shieldsco
ID: 36592260
how can I use the dtpicker similiar to the calendar to update a table using a form
0
 

Author Comment

by:shieldsco
ID: 36595052
how can I update an access table from a form using the dtpicker suggested by Peter - I received no response from him
0
 
LVL 12

Expert Comment

by:danishani
ID: 36597140
Well as I agree with DatabaseMX that using ActiveX Objects can be tricky, it would work as long as References are set propperly, but you might go for the safer solution as Peter suggested.

To get this TimePicker (UA solution by Mark) to work, check the frmDemo. In the DoubleClick Event of the txtTime you will see the code behind this. To get it to work for you simply use this:

    DoCmd.OpenForm "frmMiniTimePicker", , , , , acDialog
    ' move the focus off the date control
    Me.txtFocus1.SetFocus

Hope this helps,
Daniel
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 84
ID: 36598438
No biggie, but I'm not DatabaseMX :)

And this statement:

"it would work as long as References are set propperly"

Is most certainly not true in Access. While it may work properly on YOUR machine, there is a very good chance it will NOT work properly on other machines, even if the ref is properly set. I've seen it happen far, far too many times and cause far too much grief.

The Access environment is quite different from other COM-compliant environments, and ActiveX controls are (generally) not built to be compliant with the Access environment (has to do with the way the control exposes its interfaces and such). Even those from Microsoft are NOT compliant with the Access environment (unless they are specifically designed to do so, and the one being suggested is NOT).

That's not to say it won't work, but that instead you really, really should look at native Access methods before resorting to ActiveX controls. And, if you really, really need ActiveX controls, then move up to VB6 - or even better, make the big dive into .NET!
0
 

Author Comment

by:shieldsco
ID: 36598649
I get a compile error when I try to run the following code: DoCmd.OpenForm "frmMiniTimePicker", , , , , acDialog
    ' move the focus off the date control
    Me.txtFocus1.SetFocus

See attached screen shot

Doc1.docx
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 36598679
The error means you don't have a control named "txtFocus1" on the current document. The "Me" preface refers to whatever object your code is running in - for example, if you run this from a form named "frmCustomer", then that code would (a) open the form named frmMiniTimePicker in Dialog (i.e. Modal) mode and then (b) attempt to set the focus to a control named txtFocus1 on frmCustomer. If you're expecting something different, please indicate what you're trying to achieve.

0
 
LVL 12

Expert Comment

by:danishani
ID: 36599046
@ LSMConsulting:

Sorry for mixing you up with DatabaseMX, I don't know where that came from hehe. My apoligize for that. Point taken, thanks for the explanation. I know its not the best practise using ActiveX controls, but had no bad experience so far. I guess better avoiding it then getting in trouble later.

@ shieldsco:
Yes, change the field txtFocus1 to an existing field on your Form, or simply remove it, if you have no use for it.

0
 

Author Comment

by:shieldsco
ID: 36599059
Thanks - it seems to work fine - the data is written to my table. Nice job
0
 

Author Closing Comment

by:shieldsco
ID: 36599089
Good job
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Read about achieving the basic levels of HRIS security in the workplace.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now