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
548 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
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…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

932 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

14 Experts available now in Live!

Get 1:1 Help Now