473,382 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Date time picker - findrecord based on value

Where am I going wrong?

I have a form which has a record for each date on which I teach. It
has a subform which shows the classes that I teach that day. So I want
to be able to click on a calendar and jump to the selected day, so that
I can make plans for each class etc.

My form has a field TeachDayDate which is Date/Time, which comes from
an underlying table/query.

I want to be able to click on a control, such as DTPicker3, or the
Calendar control so that I can view the record for the chosen date.

I have followed the help and done the module stuff and pressed F5 so
that the ActiveX control is recognised.

All I can do is have a txtDTpicker show the date picked - but only
after I manually refresh the records from the toolbar. How can I force
a refresh/whatever from code?

I have tried using a filter criteria in the underlying queries
TeachDayDate: [txtDTPicker3] but this doesn't work.

I have tried
Set rs = Me.Recordset.Clone
rs.Findfirst "[TeachDayDate] = '" & Me![DTPicker3] & "'"
Me.Bookmark = rs.Bookmark
and that doesn't work either.

How can I use DTPicker3 in either expressions or queries so that I can
move to the record for the selected day?

Jan 14 '06 #1
7 4102
4004 wrote:
Where am I going wrong?

I have a form which has a record for each date on which I teach. It
has a subform which shows the classes that I teach that day. So I want
to be able to click on a calendar and jump to the selected day, so that
I can make plans for each class etc.

My form has a field TeachDayDate which is Date/Time, which comes from
an underlying table/query.

I want to be able to click on a control, such as DTPicker3, or the
Calendar control so that I can view the record for the chosen date.

I have followed the help and done the module stuff and pressed F5 so
that the ActiveX control is recognised.

All I can do is have a txtDTpicker show the date picked - but only
after I manually refresh the records from the toolbar. How can I force
a refresh/whatever from code?

I have tried using a filter criteria in the underlying queries
TeachDayDate: [txtDTPicker3] but this doesn't work.

I have tried
Set rs = Me.Recordset.Clone
rs.Findfirst "[TeachDayDate] = '" & Me![DTPicker3] & "'"
Me.Bookmark = rs.Bookmark
and that doesn't work either.

How can I use DTPicker3 in either expressions or queries so that I can
move to the record for the selected day?

What is the value of DTPicker3? Is it a date? Try
rs.Findfirst "[TeachDayDate] = #" & Me![DTPicker3] & "#"
it it is a date field.

Text fields are surrounded by quotes, dates by #, and numerics by nothing.
Jan 14 '06 #2
Yes, it is a date/time field.

I have just tried your suggestion, without any luck.

My DateTimePicker is working - it sets the value in my text box
txtDTPicker. However, I cannot use this value in the form, as
described; nothing appears to happen when the code is run.

Jan 14 '06 #3
I have just tried using the wizard to create a cmd button to open
another form where a filter is applied according to the value of
dtpicker.

frmwithDtpicker opens frmWithDates

What I see in the properties window is that the filter is attempting to
match not only the date but the time as well - hence it probably cannot
find a record that matches.

So, how do I clean up the dates/force an ignore of the time part of
the field/find a nearest match?

Suggestions gratefully recieved.

Jan 14 '06 #4
Sorry, I should have waited a few minutes until I found a bit more of
the answer myself:

part of the answer is that DateTimePicker, as its name implies, returns
a value that is a date and a time. When I changed it for an ActiveX
calendar control I found I was able to open the second form with the
correct filter - so something is working.

However, that leaves the findrecord still doing nothing.

Jan 14 '06 #5
4004 wrote:
Sorry, I should have waited a few minutes until I found a bit more of
the answer myself:

part of the answer is that DateTimePicker, as its name implies, returns
a value that is a date and a time. When I changed it for an ActiveX
calendar control I found I was able to open the second form with the
correct filter - so something is working.

However, that leaves the findrecord still doing nothing.


A Date field has a time of 00:00:00

A field that stores a value like Now() will, for the most part never
have a value of 00:00:00 except by luck

You could create a column in your query recordsource.
DateWOTime : Cdate(format([txtDTPicker3],"short date"))
This basically strips the time off your field. Now search for DateWOTime.

Some people can get confused on dates that store Now() data. For
example, you may want to select all records between 1/1/2006 and
1/2/2006. Then enter
Between #1/1/2006# And #1/2/2006# in the query.
Then they get surprised because only recs with for 1/1 are returned.
That's because they're asking for records between 1/1/2006 00:00:00 and
1/2/2006 00:00:00. Better to make it 1/3/2006 to select the records for
1/2/2006.

Jan 15 '06 #6
Thanks for that. However, while the DTPicker appears to return a date
and time (no surprise there I suppose) and so will not match the field
I want, I believe that the ActiveX calendar control returns just a date
- so should not cause a problem requiring stripping off the time to
leave the date.

So, my Calendar control gives me the date, as I want it.

My txtDate which is fed by the Calendar shows me that the Calendar is
working and can be read.

However, I cannot then either use the date as a filter in my form or
use the FindRecord code (as above) to move to the first instance of a
date.

The code works for other field types in other forms.

But...having just copied it below, perhaps the problem lies in the
(Code as Integer) part? Does that mean that I will need to convert my
DateTime field in my recordset query to an Integer so that I can match
it?

Private Sub Calendar3_Updated(Code As Integer)
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.Findfirst "[Date] = #" & Me![Calendar3] & "#"

Me.Bookmark = rs.Bookmark

End Sub

Jan 15 '06 #7
Many experienced Access users do not use the Calendar Control. You are
finding out why, perhaps.

1. Is your function actually called? Try inserting
MsgBox "[Date] = #" & Me![Calendar3] & "#"
As its first line and then run it to see. If it's not actually called
see if you can use some other event of of the control or the textbox to
do what you want.

2. Is your criteria string in the correct format? The message box
should show something like:
[Date] = #1/15/2006#

Typically Access/Jet needs the date as
[Date] = #1/15/2006#
or
[Date] =#2006-01-15#.

It can also deal with a numerical value:
[Date] =38732

Jan 15 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Adrian Parker | last post by:
Hi. I have a date time picker in my program which uses ADO to read from an Access database. It works perfectly, unless the database is empty (no records) when opened. When you try to open an...
3
by: TD | last post by:
This code doesn't work. Every posting I can find suggests that it should. If TypeOf controlname Is DTPicker then do something here End If I am using the Date Time Picker control and wish to...
7
by: XmlAdoNewbie | last post by:
Hi All, I am wondering if it is possible to allow nulls or empty strings when it comes to the datetimepicker control. I have an app with a few datetimepickers on it and there are some instances...
4
by: Rethish | last post by:
Hi All, I am developing an application in VB.net. I am using .Net Datetime picker control to manage the date. But I am not able to assign null/Empty value to the control. I found the property...
4
by: Michael Turner | last post by:
Hi Guys I have two DateTime pickers one shows the Date and the other the time, this is a requirement of the solution. The problem I have is that when the time is saved to the sql database into a...
5
by: Johnaton | last post by:
hi, I have this problem with the date time picker, when I bind the control to data table and add new record, it is ok, however, if I delete all records via a button using the...
4
by: Michel Posseth [MCP] | last post by:
I have a problem with the date time picker validate event wich i believe is a bug How to reproduce : throw on a form a date time picker control and a textbox control select the validating...
3
by: luanhoxung | last post by:
hi all ! i have a date & time picker control bound to 1 field. it worked fine. But i always get the message :" Can't set value to Null when checkbox properties = FALSE" when i open my form. there...
0
by: fredloh | last post by:
i have a tab control on my form. i then have several microsoft date and time picker control on the tab control. when i select a date on any of the date and time picker control, the result of the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.