473,406 Members | 2,894 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,406 software developers and data experts.

(2) Date Instances that I need help with!

First what I need help with is in a report that I have that I have hauled multiple truck loads with a particular truck on a particular day and I want on the report to show me on the footer of the report how many days each truck worked. I can get the total number of loads each truck hauled for that particular time frame in my report with the count functin but when it comes to disreguarding the multiple records on that particular date icantmakethat happen.

The other thing that I need is that I would like to be able to create myself a hotkey for either a consecutive date or possibly even a consecutive ticket number formy forms. When I use one of my forms for timecard entry I would like tobe able to just press a function key andbring up the next consecutive date finding that date off the last date entered. I have searched your forum for help with either of these date functions with no luck.

Your help willbe greatly appricated.
Rich
Feb 3 '07 #1
4 1779
ADezii
8,834 Expert 8TB
First what I need help with is in a report that I have that I have hauled multiple truck loads with a particular truck on a particular day and I want on the report to show me on the footer of the report how many days each truck worked. I can get the total number of loads each truck hauled for that particular time frame in my report with the count functin but when it comes to disreguarding the multiple records on that particular date icantmakethat happen.

The other thing that I need is that I would like to be able to create myself a hotkey for either a consecutive date or possibly even a consecutive ticket number formy forms. When I use one of my forms for timecard entry I would like tobe able to just press a function key andbring up the next consecutive date finding that date off the last date entered. I have searched your forum for help with either of these date functions with no luck.

Your help willbe greatly appricated.
Rich
I'm a little hazy on the first part, and would like a little more detail and actual data, but I can help you on part 2:

'Declare a Public Variable
Expand|Select|Wrap|Line Numbers
  1. Public MyControl As Control
'Create a Public Function Procedure
Expand|Select|Wrap|Line Numbers
  1. Public Function fInsertConsecutiveDate()
  2. On Error GoTo Err_fInsertConsecutiveDate
  3.  
  4.   MyControl = DLast("[Your Date]", "Your Table") + 1
  5.  
  6. Err_fInsertConsecutiveDate
  7.   Exit Function
'On the GotFocus Event of any Control on which you want this Hot Key functionality, set the 'complete reference' to the Control. We will use [txtTest] on frmTest as an example
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtTest_GotFocus()
  2.   Set MyControl = Forms!frmTest![txtTest]
  3. End Sub
Create an AutoKeys Macro
__Macro Name - +{F10}
__Action - RunCode
__Function Name - fInsertConsecutiveDate ()

Now, when the Focus is on [txtTest] and you press SHIFT+F10, the next consecutive Date after the last Date entered will be placed in the Text Box. If you are not interested in a Hot Key, you can assign = DLast("[Your Date]", "Your Table") + 1 to the Default Value of any Text Field for which you want this functionality. When you add a New Record, the next consecutive Date after the last Date will automatically be entered into this Field.
Feb 3 '07 #2
The first of my question has to do with my report. I will try to be more clear.
What I would like to have is the amount of days that the truck worked. I have data in my reports stating that truck a hauled 3 loads all with the same date. Driver of truck a hauled all these loads and I need to know how many days per reporting period each driver and truck worked. So then what I can do is figure out an average for the reporting period on what the driver as well as the truck made per day. I can take care of the average but just need help figuring out how to actually count days vs. counting records or entries.

Thanks
Rich
Feb 3 '07 #3
ADezii
8,834 Expert 8TB
The first of my question has to do with my report. I will try to be more clear.
What I would like to have is the amount of days that the truck worked. I have data in my reports stating that truck a hauled 3 loads all with the same date. Driver of truck a hauled all these loads and I need to know how many days per reporting period each driver and truck worked. So then what I can do is figure out an average for the reporting period on what the driver as well as the truck made per day. I can take care of the average but just need help figuring out how to actually count days vs. counting records or entries.

Thanks
Rich
__1 Create a Query with only 2 Fields: [Driver] and [Date] (qryDriverAndDate).
__2 Set Criteria for the Date Range within the [Date] Field.
__3 Set the Unique Values Property to Yes. This will give you Unique values for each Driver and Date combination (If Ted made 6 runs on 12/12/2006, he would only show up once in the Query).
__4 Run the following code to determine how many days per Reporting Period each Driver worked.
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database, MyRS As DAO.Recordset
  2.  
  3. Set MyDB = CurrentDb()
  4.  
  5. 'Get a 'Unique' lsit of all Drivers, use your Table Name.
  6. Set MyRS = MyDB.OpenRecordset("SELECT DISTINCT [Driver] From tblTruck", dbOpenDynaset)
  7.  
  8. Do While Not MyRS.EOF
  9.   Debug.Print MyRS![Driver] & " worked " & DCount("[Driver]", "qryDriverAndTruck", "[Driver]='" & MyRS![Driver] & "'") & _
  10.               " day(s) this period"
  11.   MyRS.MoveNext
  12. Loop
  13.  
  14. MyRS.Close
Typical Output would be:
Expand|Select|Wrap|Line Numbers
  1. Frank worked 1 day(s) this period
  2. George worked 1 day(s) this period
  3. Lou worked 2 day(s) this period
  4. Steve worked 1 day(s) this period
  5. Steven worked 1 day(s) this period
  6. Ted worked 4 day(s) this period
  7. Tom worked 2 day(s) this period
NOTE: For determining how many days each truck was utilized per period, make appropriate substitutions. I strongly feel that one of the other Experts will come up with a better solution, but for now this is all I have to offer.
Feb 4 '07 #4
NeoPa
32,556 Expert Mod 16PB
If doing this in a query I would advise having a subquery (Subqueries in SQL) which groups at the first level with a sum() field for the item. In the outer query you can use Count() to get the number of days used and Sum() to get the overall sum.
In a report, use Sorting and Grouping to do something similar. You will need group footers to Sum() and Count() the items.
Feb 5 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
1
by: Robert Mark Bram | last post by:
Howdy All! I am trying to write a very brief comparison of the Date and Math objects in terms of instance v static objects. What I have below is my best so far. Any criticisms or suggestions are...
11
by: lduperval | last post by:
Hi, I`m trying to do date calculations in three types of time zones: local, GMT and specified. The issue I am facing is that I need to be able to specify a date in the proper time zone, and I`m...
6
by: kevin carter | last post by:
hi i have a table conataining several fields one of which is date i want to be able to search the table on the date field using code. the code below generates the query from a form, however i get...
3
by: hasanainf | last post by:
Hi all, What will be the best database design for an inventory control that uses expiry date for its products. Over a period of time, a particular product will have many expiry date and that...
7
by: Jerome | last post by:
Hallo, I know a lot has already been told about date/time fields in a database but still confuses me, specif when dealing with SQLserver(Express). It seems that sqlserver only accepts the date in...
12
by: Rob Meade | last post by:
Hi all, Ok - I've come from a 1.1 background - and previously I've never had any problem with doing this: Response.Write (Session("MyDate").ToString("dd/MM/yyyy")) So, I might get this for...
3
by: Jon Paal | last post by:
looking for date-picker which is made up of three dropdowns, month/day/year, which are interconnected to show correct combination upon change of any one dropdown. Should allow for multiple...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.