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

Advanced reports

157 100+
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

---
Aug 22 '07 #1
3 1714
MrDeej
157 100+
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
Aug 22 '07 #2
MrDeej
157 100+
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:

Expand|Select|Wrap|Line Numbers
  1.  Dim vd As Date
  2.  Dim db   As DAO.Database
  3.  Dim rst  As DAO.Recordset
  4.  
  5. DoCmd.RunSQL "DELETE * FROM [IBD temp expiredate]"
  6.  
  7.   Set db = Access.Application.CurrentDb
  8.   Set rst = db.OpenRecordset("TBL product info", dbOpenDynaset)
  9.  
  10.   With rst
  11.     .MoveLast
  12.     .MoveFirst
  13.  
  14.     Do While .EOF = False
  15.  
  16.         pnr = !ProductNumber
  17.         exp = !ExpiryDate
  18.         check = DLookup("[Exception number of months]", "TBL exception products ", "Productnumber=" & vnr)
  19.         If Not IsNull(check) Then
  20.  
  21.  
  22.  
  23.             year = "20" & Mid(exp, 2, 2)
  24.             month = Mid(exp, 4, 2)
  25.             date = Right(exp, 2)
  26.  
  27.  
  28.             vd = Date & "." & month & "." & year
  29.             vd2 = DateAdd("m", check, vd)
  30.  
  31.             newexp = "1" & Right(vd2, 2) & Mid(vd2, 4, 2) & Left(vd2, 2)
  32.  
  33.             Dim rst3 As New ADODB.Recordset
  34.  
  35.             rst3.Open "[IBD temp expiredate]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  36.                 With rst3
  37.                 .AddNew
  38.                 ![Product number] = pnr
  39.                 ![expiredate] = newexp
  40.                 .Update
  41.             End With
  42.             rst3.Close
  43.             Set rst3 = Nothing
  44.  
  45.         Else
  46.  
  47.             Dim rst4 As New ADODB.Recordset
  48.  
  49.             rst4.Open "[IBD temp expiredate]", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
  50.                 With rst4
  51.                 .AddNew
  52.                 ![Product number] = pnr
  53.                 ![Expiredate] = exp
  54.                 .Update
  55.             End With
  56.             rst4.Close
  57.             Set rst4 = Nothing
  58.  
  59.         End If
  60.  
  61.         .MoveNext
  62.     Loop
  63.   End With
  64.  
  65.   Set rst = Nothing
  66.   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
Aug 22 '07 #3
MrDeej
157 100+
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 :)
Aug 22 '07 #4

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

Similar topics

2
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...
5
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...
4
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...
2
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...
2
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...
3
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...
10
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...
3
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...
3
isben22
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...
2
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...
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
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
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
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.