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
552 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

820 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