473,386 Members | 1,969 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,386 software developers and data experts.

DLookup return date from database

I'm running Access 2003 on WinXP

Here is my problem:

I'm trying to lookup a date in a table from a query data. The query
include the following: Query = Qry_Invoice and Table = Tbl_Friday

Qry_Invoice contains invoice data like: supplier name, invoice date,
payment date, purchase order.

Tbl_Friday contains all the fridays from 2003 to 2007.

Since friday is the chosen date for the weekly accounting check run, my
issue is I'm trying to lookup the nearest friday to the payment date.
Once I get my result, I will be able to sort and run the weekly print
check reports automatically.

For example: I have an invoice form a supplier XYZ Inc. which is dated
2005-9-15 (Invoice_Date), the supplier has 45 days terms so the
Payment_date is 2005-10-30. This date appear between two fridays
2005-10-28 & 2005-11-04. I either get the first date of the table or
the last. How can I run a function to get my result?

I've tried the expressions DMax, DMin and DLookup with no success by
grouping the database. This seemed to be the most logical way until
now...

Thanks

Nov 13 '05 #1
4 2762
How about doing something like a summary query, and using MIN>SomeDate
or MAX<SomeDate. Then you can return it anywhere you want or use DMAX
or DMIN...

Nov 13 '05 #2
"Beejer" <bj********@yahoo.ca> wrote in
news:11**********************@g43g2000cwa.googlegr oups.com:
I'm running Access 2003 on WinXP

Here is my problem:

I'm trying to lookup a date in a table from a query data. The
query include the following: Query = Qry_Invoice and Table =
Tbl_Friday

Qry_Invoice contains invoice data like: supplier name, invoice
date, payment date, purchase order.

Tbl_Friday contains all the fridays from 2003 to 2007.

Since friday is the chosen date for the weekly accounting
check run, my issue is I'm trying to lookup the nearest friday
to the payment date. Once I get my result, I will be able to
sort and run the weekly print check reports automatically.

For example: I have an invoice form a supplier XYZ Inc. which
is dated 2005-9-15 (Invoice_Date), the supplier has 45 days
terms so the Payment_date is 2005-10-30. This date appear
between two fridays 2005-10-28 & 2005-11-04. I either get the
first date of the table or the last. How can I run a function
to get my result?

I've tried the expressions DMax, DMin and DLookup with no
success by grouping the database. This seemed to be the most
logical way until now...

Thanks

What you are wanting to do with the invoice_date is to add the
number of days to make it the following friday.

The weekday([invoice_date],vbSaturday) function returns the
number 1 for saturday, 2 for sunday, 3 for monday through 7 for
friday, so embedding 7- that value to
dateadd("d",7-weekday([]invoice_date],vbSaturday),invoice_date)
will give you just the fridays. use that calculated date to sort
and summarize, you won't even need your table of fridays..

--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #3
Thanks Bob, I haven't thought of that function. I've tried to implement
your exact function but didn't quite work. Although, it inspired me to
work around it to figure out a solution. Here my result :

Duedate: DateAdd("d";(6-Weekday([Invoice_Date]));[Invoice_Date])

It seems to be working very nicely in the database.

Regards

Beejer

Nov 13 '05 #4
"Beejer" <bj********@yahoo.ca> wrote in
news:11*********************@g44g2000cwa.googlegro ups.com:
Thanks Bob, I haven't thought of that function. I've tried to
implement your exact function but didn't quite work. Although,
it inspired me to work around it to figure out a solution.
Here my result :

Duedate:
DateAdd("d";(6-Weekday([Invoice_Date]));[Invoice_Date])

It seems to be working very nicely in the database.

Regards

Beejer

Glad to have helped.
--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #5

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

Similar topics

1
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one...
4
by: David B | last post by:
I have a Public function which creates a back up copy of a back end. It works fine with the source path and source file as C:\folder\etc. I thought I would try to store the paths in a table so...
2
by: Sue | last post by:
I sent an e-mail below and got a responese but i still have the #error message in the subject below: Can someone help me: questions and replies are separted by ----- -------My Questions: I have...
0
by: Tony Williams | last post by:
I have posted a number of posts in the Access newsgroups concerning my problem with DLookup. I have had a number of the experts with helpful suggestions but I still can't get it to work! This is...
2
by: chris.thompson13 | last post by:
I am having a problem setting the criteria part of the DLookup method correctly and am consequently getting an error message. I have a database of staff duties, part of which is a query (qryDaily)...
2
by: boyleyc | last post by:
Hi all the following code works perfectly well. Basically it populates a series of check boxes on my form, depending on whether dlookup finds an associated record. The problem i have is that...
3
by: hrreece | last post by:
I am trying to use the Dlookup expression in a macro to pull the value from the "Price" field in the following query. The query works fine and the Dlookup function did as well until I added a new...
3
reginaldmerritt
by: reginaldmerritt | last post by:
I'm using Dlookup to search a table for the first record it comes across that has a date >= the date i specifiy. e.g. formateddate = format(Me.SelectedDate,"mmddyy") VarX = DLookup("",...
30
by: DH22 | last post by:
Access 03 I'm currently having an issue using Dlookup when trying to reference a query (criteria syntax) Currently I have 1 table, which is L_Emps (which contains Employee_ID as my key...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
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
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,...

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.