Hello!
I am somewhat stuck on this problem.
I have 1 table which contains an expiry date for products, named TBL productinfo and one table wich contains the exception in how long the product is ok'd for sale called TBL exception products.
Fields in the tables TBL productinfo
Product number
Expiry date (number format) e.g.: 1071201 is in realitiy 01.12.2007 TBL exception products
Product number
Exception number of months (number format) e.g.: 5
The thing i need to do is that i need a report on the products which are 3 months ahead in time. Easy with just TBL productinfo. Then i use <1071201 as criteria.
Problem is that when a product is apperent in the TBL exception products with a "Exception number of months" value of 5 it should also be a part of the list even if the expiry date is 1080201. And if the criteria is 1071201 and a product has an post in TBL exception products with "exception number of months" of 1 it shouldnt come on the list before the expiry date is 1071001 even though the criteria is 1071201
In short words, i need to make a report which makes all products in TBL product info to appear on the list when it has less than 3 months to expiry date unless it has a post in TBL exception products and then should automaticly adjust the criteria to what stands in "Exception number of months"
Possible soloutions: 1. Make a sql sentence which checks each product if it has a connection to the "exception" table, where it uses the post in exception if any, but when it dosent have a exception it should use the standard 3 month
---
3 1714 2. Make a query which adds up the expiry date using the "exceptions" table. Problem is that it needs to add up e.g. 5 months to a 1071101 date formatted with number format. It would be easy if it wasent for the year change that happends after 1071201. Then i have to format the string to be a date format and then add 5 or 3 or 1 or whatever months to the date format and then format it back so that i can use it as criteria..
I dont know how to do this in sql code. I may manage to do this in vba but then i dont know how to make use of this in a report.
hmmmm
Ok. I have managed to make a code that does the job (in a way) but of course this need a triple super computer to be somewhat fast.
take a look: - Dim vd As Date
-
Dim db As DAO.Database
-
Dim rst As DAO.Recordset
-
-
DoCmd.RunSQL "DELETE * FROM [IBD temp expiredate]"
-
-
Set db = Access.Application.CurrentDb
-
Set rst = db.OpenRecordset("TBL product info", dbOpenDynaset)
-
-
With rst
-
.MoveLast
-
.MoveFirst
-
-
Do While .EOF = False
-
-
pnr = !ProductNumber
-
exp = !ExpiryDate
-
check = DLookup("[Exception number of months]", "TBL exception products ", "Productnumber=" & vnr)
-
If Not IsNull(check) Then
-
-
-
-
year = "20" & Mid(exp, 2, 2)
-
month = Mid(exp, 4, 2)
-
date = Right(exp, 2)
-
-
-
vd = Date & "." & month & "." & year
-
vd2 = DateAdd("m", check, vd)
-
-
newexp = "1" & Right(vd2, 2) & Mid(vd2, 4, 2) & Left(vd2, 2)
-
-
Dim rst3 As New ADODB.Recordset
-
-
rst3.Open "[IBD temp expiredate]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
-
With rst3
-
.AddNew
-
![Product number] = pnr
-
![expiredate] = newexp
-
.Update
-
End With
-
rst3.Close
-
Set rst3 = Nothing
-
-
Else
-
-
Dim rst4 As New ADODB.Recordset
-
-
rst4.Open "[IBD temp expiredate]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
-
With rst4
-
.AddNew
-
![Product number] = pnr
-
![Expiredate] = exp
-
.Update
-
End With
-
rst4.Close
-
Set rst4 = Nothing
-
-
End If
-
-
.MoveNext
-
Loop
-
End With
-
-
Set rst = Nothing
-
Set db = Nothing
I am embarrased topost so bad code on the forum. Please kick my in the ass and tell me a easier way to solve this case if there is any
Ok. I give it 16 hours before i implement and start using this sucy code to do the task (point of no return).
Lets hope someone come with some comments before that :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: intl04 |
last post by:
Is it possible to create an Access database that searches on multiple
fields or can process multiple search keywords (for a photos database)
or is it best to just use third-party software such as...
|
by: Pachydermitis |
last post by:
Hi all I have 3 horrible questions:
I am using an Access 2000 frontend with an Access 2000 db as the
backend.
I have built an automatic update feature that checks the front version
against the...
|
by: Nhmiller |
last post by:
This is directly from Access' Help:
"About designing a query
When you open a query in Design view, or open a form, report, or datasheet and
show the Advanced Filter/Sort window (Advanced...
|
by: B.Newman |
last post by:
I've got some VB.NET code that *should* get a list of reports from an
Access MDB and populate a list box with them.
It doesn't detect any of the reports at all. oAccess.Reports.Count
comes up as...
|
by: z.ghulam |
last post by:
At the moment my co uses a spreadsheet to note how many orders each
engineer is assigned and this is updated manually. I've thought about
transferring this to Access and have thought of two...
|
by: VMI |
last post by:
I know this may not be the best NG for this, but I feel you guys know more
about this than any of the other NGs.
I need to build several simple reports (over 50 of them and they get their
data...
|
by: jklimek |
last post by:
I'm currently a Delphi developer (my day job) but at my company we only
write custom web application/database stuff, so we never really get
into anything advanced. However, I know enough about...
|
by: lmawler |
last post by:
Hi everyone,
I'm making reports that are based on queries, and the data has several levels of grouping.
I have set up a report with several nested group headers, but I'm currently stuck where...
|
by: isben22 |
last post by:
I have been searching through references trying to find methods for developing reports. Many of the "advanced" reports talk about GROUPING and ORDERING.
What about special printing requirements? I...
|
by: Fred |
last post by:
I know the basics of Access 2003 to the point I can made simple queries and
very simple reports. I would like to know a bit more. Can anyone point me
in the way of tutorials or literature so I...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |