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

Pull date that is less than or equal to another date field

2
this function needs to review the entry date of a particular task ID and match it to table which houses task IDs, their value and the "go live" date for the particular values

TblTimings houses the data regarding the go live dates and task values.

tblData has the entry date, and it is currently set up to be pulled into the query that this function would be plugged into.

i.e. taskID 2 had a value of 2.0 beginning on 1/1/10, the value was updated on 6/1/10 to be 30.0

Now the people using the database enter their info for entry date on 4/1/10.

I want the function to match 4/1/10 to see that taskID 2 had a value of 2.0 on 4/1/10.

I was trying to get it to review DateDiff that was the smallest value without being less than zero.

I am pretty new to coding, so I was wondering if someone could take a look and let me know what they think...

Thanks
D

Expand|Select|Wrap|Line Numbers
  1. Function GetTiming(EntryDate, TaskID) As Double
  2.         Dim sqlstr As String
  3.         Dim db As Database
  4.         Dim rs As Recordset
  5.  
  6.  
  7.  
  8.  
  9. sqlstr = "SELECT tblTimes.TimingID, tblTimes.TaskID, tblTimes.LiveDate, tblTimes.Timing FROM tblTimes WHERE (((tblTimes.TaskID) = " & TaskID & "))ORDER BY tblTimes.LiveDate DESC;"
  10.  
  11.         Set db = CurrentDb
  12.  
  13.         Set rs = db.OpenRecordset(sqlstr)
  14.  
  15.  
  16.         If rs.RecordCount = 0 Then
  17.             GetTiming = 0
  18.             'MsgBox "No records found"
  19.         Exit Function
  20.         End If
  21.         If rs.RecordCount = 1 Then
  22.             GetTiming = rs!Timing.Value
  23.         Exit Function
  24.         End If
  25.         Do Until Not rs.EOF
  26.         Debug.Print TaskID & ": " & rs!Timing.Value
  27.             If DateDiff("d", EntryDate, rs!LiveDate.Value) >= 0 Then GetTiming = rs!Timing.Value: Exit Do
  28.         rs.MoveNext
  29.         Loop
  30.         rs.Close
  31.  
  32.  
  33.  
  34.  
  35. End Function
  36.  
Update:
Access 2003, sorry I forgot that. This is my first question on the boards. Newbie. :)
Aug 25 '11 #1
3 2482
NeoPa
32,556 Expert Mod 16PB
I read this through a couple of times and I have no better idea what you're asking now than I had before I started.

Perhaps outlining the table structures and providing some example data and what's required in the context of that data might be a better way to phrase your question Dan.
Aug 25 '11 #2
Dan G
2
Sorry. This is a system for tracking productivity

tblData captures the person's input

NetID - identifies the person entering the data
Count - their count of each work unit completed
TaskID (id for type of task - links to table of tasks
EntryDate (for date they are filling in data for)
InputDate (time stamp)

tblTimes
TimingID - key
TaskID
Timing - the timing assigned to the particular task
LiveDate - the date at which this particular timing went into use

Times tables holds this info:

task timing livedate
1 5minutes Dec 31, 2010
1 10 minutes Jan 10, 2011

Data table holds this info:
John Doe Jan 1, 2011 - task#1 - 45 units

John Doe Jan 15, 2011 - task#1 - 30 units


I want to be able to run function that checks which livedate/timing was active for the dates.

So it would return the 5 minute value for the first line of data because the live date was effective 12/31/10, while the second one would get the 10 minute value because it was after the 1/10/11 live date.

Hopefully this makes a little more sense.

Thanks
Aug 29 '11 #3
NeoPa
32,556 Expert Mod 16PB
Frankly Dan, though this is a much better stab at it, trying to follow your meaning is severely hampered by the numerous inconsistencies in your description. Use of undefined terms (They mean something to you but not anyone else.), displaying example data in an order which doesn't even match the order in the table layout provided. I don't want to put you down, but you need to understand that asking a question takes care and application to the task if anyone is to read it and make enough sense of it to help. I'm afraid I gave up after trying a few times to guess what the question probably should have said (in all the gaps where what you posted didn't add up).
Aug 30 '11 #4

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

Similar topics

5
by: Pan Yang Bin | last post by:
Hi, I using the following script to output 10 o'clock, the first two return corrent result, and i also check the year, month, day, hour, minute, second function they all return same result. but...
8
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them...
7
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the...
3
by: Golan | last post by:
Hi all, I need to write a code which gets a date (in format 'YYYYMMDDhh24MISS') and number of seconds (X), and returns the date (again in format 'YYYYMMDDHH24MISS') that is X seconds prior to...
8
by: libsfan01 | last post by:
how can i use regular expressions to ensure a mysql format date entry in a text field? thanks marc
1
by: saratogajoe | last post by:
I am building an access database for auditing of health care charts . I only want to select audit records of charts audited from a certain date and to another date
23
Dököll
by: Dököll | last post by:
Hey Gang! I am sure thi is simple and will find answers here. Can't do so as of now, but will when I get home> It looks like below code is not allowing me to set it so Contact date canot be...
15
by: kpfunf | last post by:
I have one table of transactions, another table of price quotes. Transactions are nearly daily; quotes are periodic, roughly once per week. In a query, I want to pull the oldest (or least date)...
12
by: klbrownie | last post by:
Hello, I am trying to get a date field to autofill based on the date of another date field. I want the autofilled date to be 30 days after the other date. For example, if the user has entered...
2
by: bytes access nubie | last post by:
When a query is run, i want a prompt displayed allowing the user to enter < DATE to find all records less than the specific date. e.g. < 1/1/2011. I know how to do that with a start date AND...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.