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

Looping Through a RecordSet to Generate a report -- DAO / ADDO ??

I would like to be able to create a recordset in MS Access 2000 that
allows a macro to run and create a report for each ID [Bill of Lading
Number] that appears in the recordset. So I thought that I would use a
scheduling program to start the database and then have an AutoExec
Macro start the process.

My issue is that I can not seem to get any results to generate a
report. I am somewhat confused as to what the difference is in DAO and
ADDO.

Here is the code that does not seem to be working.

Public Sub PrintReport()

Dim rs As Object ' When I tried as a Recordset or a ADDO.Recordset
I recieved a runtime error.
Dim SQLText As String

SQLText = "SELECT tblStopInfo.[Bill of Lading Number],
tblStopInfo.[Stop Number], " & _
"tblSCAC.[CARRIER SCAC], tblSCAC.[CARRIER NAME],
tblLoadInformation.[Trailer Number], " & _
"tblLoadInformation.[Equipment Type], tblLoadInformation.[Load
Number]," & _
"tblLoadInformation.[BILLS RECEIVED DATE], tblLoadInformation.[Bills
Recieved Time], " & _
"tblLoadInformation.[Equipment Length], tblLoadInformation.[IB -
OB]," & _
"tblStopInfo.[Consignee Name], tblStopInfo.[Consignee Name 2], " & _
"tblStopInfo.[Consignee Address], tblStopInfo.[Consignee Address 2],
" & _
"tblStopInfo.[Consignee City], tblStopInfo.[Consignee State], " & _
"tblStopInfo.[Consignee Zip], tblStopInfo.[Order Number],
tblStopInfo.Pieces," & _
"tblStopInfo.Weight, tblStopInfo.[Contact Name],
tblStopInfo.[Original Appt Date]," & _
"tblStopInfo.[Original Appt Time], tblStopInfo.[Contact Phone],
tblStopInfo.Comments, " & _
"tblLoadInformation.[Email Sent]" & _
"FROM tblSCAC INNER JOIN (tblLoadInformation INNER JOIN tblStopInfo
ON " & _
"tblLoadInformation.[Bill of Lading Number] = tblStopInfo.[Bill of
Lading Number]) " & _
"ON tblSCAC.ID = tblLoadInformation.[Carrier SCAC Code]" & _
"WHERE (((tblLoadInformation.[Email Sent]) Is Null))" & _
"ORDER BY tblStopInfo.[Bill of Lading Number], tblStopInfo.[Stop
Number];"
Set rs = CurrentDb.OpenRecordset(SQLText)
If Not rs.BOF Then
rs.MoveFirst

With rs
Do While Not rs.EOF

DoCmd.OpenReport "qryCreate_BOL_Report", acViewPreview

Loop

rs.MoveNext
End With
End If

End Sub

Please Help. Thanks in Advance.

Nov 13 '05 #1
1 2754
You don't need the recordset at all for the report. If what you show in SQL
is a stored query, just set the recordsource of the report to the query and
open the report in preview mode. If the query is not stored, create the
query and save it. Also realize that your Where clause limits the records
returned to only those where there was no email sent. If emails were sent to
all carriers, you will get no records in your report.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"Robert Davis" <rl******@charter.net> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
I would like to be able to create a recordset in MS Access 2000 that
allows a macro to run and create a report for each ID [Bill of Lading
Number] that appears in the recordset. So I thought that I would use a
scheduling program to start the database and then have an AutoExec
Macro start the process.

My issue is that I can not seem to get any results to generate a
report. I am somewhat confused as to what the difference is in DAO and
ADDO.

Here is the code that does not seem to be working.

Public Sub PrintReport()

Dim rs As Object ' When I tried as a Recordset or a ADDO.Recordset
I recieved a runtime error.
Dim SQLText As String

SQLText = "SELECT tblStopInfo.[Bill of Lading Number],
tblStopInfo.[Stop Number], " & _
"tblSCAC.[CARRIER SCAC], tblSCAC.[CARRIER NAME],
tblLoadInformation.[Trailer Number], " & _
"tblLoadInformation.[Equipment Type], tblLoadInformation.[Load
Number]," & _
"tblLoadInformation.[BILLS RECEIVED DATE], tblLoadInformation.[Bills
Recieved Time], " & _
"tblLoadInformation.[Equipment Length], tblLoadInformation.[IB -
OB]," & _
"tblStopInfo.[Consignee Name], tblStopInfo.[Consignee Name 2], " & _
"tblStopInfo.[Consignee Address], tblStopInfo.[Consignee Address 2],
" & _
"tblStopInfo.[Consignee City], tblStopInfo.[Consignee State], " & _
"tblStopInfo.[Consignee Zip], tblStopInfo.[Order Number],
tblStopInfo.Pieces," & _
"tblStopInfo.Weight, tblStopInfo.[Contact Name],
tblStopInfo.[Original Appt Date]," & _
"tblStopInfo.[Original Appt Time], tblStopInfo.[Contact Phone],
tblStopInfo.Comments, " & _
"tblLoadInformation.[Email Sent]" & _
"FROM tblSCAC INNER JOIN (tblLoadInformation INNER JOIN tblStopInfo
ON " & _
"tblLoadInformation.[Bill of Lading Number] = tblStopInfo.[Bill of
Lading Number]) " & _
"ON tblSCAC.ID = tblLoadInformation.[Carrier SCAC Code]" & _
"WHERE (((tblLoadInformation.[Email Sent]) Is Null))" & _
"ORDER BY tblStopInfo.[Bill of Lading Number], tblStopInfo.[Stop
Number];"
Set rs = CurrentDb.OpenRecordset(SQLText)
If Not rs.BOF Then
rs.MoveFirst

With rs
Do While Not rs.EOF

DoCmd.OpenReport "qryCreate_BOL_Report", acViewPreview

Loop

rs.MoveNext
End With
End If

End Sub

Please Help. Thanks in Advance.

Nov 13 '05 #2

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

Similar topics

2
by: JP SIngh | last post by:
Hi All Please can someone help me solve this issue. I have a database table the structure of which are given below. Profile Table EmployeeNumber FirstName
2
by: JP SIngh | last post by:
Hi All I have threee tables like the one below and i would like to ask if it is possible to display the data from all three tables using a single recordset in ASP. TABLE - tblList id -...
22
by: Gerry Abbott | last post by:
Hi all, I having some confusing effects with recordsets in a recent project. I created several recordsets, each set with the same number of records, and related with an index value. I create...
1
by: Zlatko Matić | last post by:
Hello. I have a MS Access front end/PostgreSQL back-end combination. There is a report with nested graph (linked master/child fields). I used saved pass-through queries for both Record Source of...
1
by: tonyaccess | last post by:
Hi, I hope you may be able to help a coding novice. I have a fairly simple db which extracts data to a report via a query, my problem is the report is three pages per record set and a total of...
11
by: Jim Whitaker | last post by:
Expand full for viewing... I have a parent/child table. The basic setup is as follows: The parent table is called load sheet. It has fields such as Tripno, carrier, loaddate, etc. The child...
1
by: Ryan | last post by:
Hello. I was hoping that someone may be able to assist with an issue that I am experiencing. I have created an Access DB which imports an Excel File with a particular layout and field naming. ...
6
by: Oko | last post by:
I'm currently developing an MS Access Data Project (.adp) in MS Access 2002. One of the reports within the DB uses data that is Dynamic and cannot be stored on the SQL Server. To resolve this, I...
8
by: clloyd | last post by:
I have a report that loops through multiple records to combine one field with multiple results into one record. The code is as follows: Private Sub Report_Open(Cancel As Integer) Dim...
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
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
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,...
1
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
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
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: 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.