473,671 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GENERATE report/query on the fly...

98 New Member
I have included a snip of my code. I am trying to output my results to a report or a query. Right now I can see my results in the immediate window due to my DEBUG command. how can I take these results and create a report/query on the fly? Thanks in advance for any help...its probably simple and I just can't see it!!
.........

Do Until rs2.EOF
Do Until rs1.EOF
If rs2!Symbol = rs1!Symbol Then
If rs1!MarketPrice <> -5.25 Then
Debug.Print rs1!LocateDate, rs1!Symbol, rs1!MarketPrice
'rs1.MoveNext
Exit Do
Else
rs1.MoveNext
End If
Else
rs1.MoveNext
Oct 26 '06 #1
14 8825
NeoPa
32,569 Recognized Expert Moderator MVP
Not only can you not push these results to a Form or Report, you can't access the underlying data of a Form or report either.
I hope I'm wrong on this because, like yourself, I feel it should be possible.
I've been trying on and off for years though :-(

Someone contradict me please.
Oct 26 '06 #2
ineedahelp
98 New Member
Am I let with just writing them to a temporary table and then using this table as the recordset of my report?
Oct 26 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
You need something like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Function writeTextFile()
  3. Dim fhandle1 As Integer
  4. Dim fline As String
  5.     'open the text file to be written to
  6.     fhandle1 = FreeFile
  7.     Open "Full path to text File" For Output Access Write As #fhandle1
  8.  
  9.     Do Until rs2.EOF
  10.         Do Until rs1.EOF
  11.             If rs2!Symbol = rs1!Symbol Then
  12.                 If rs1!MarketPrice <> -5.25 Then
  13.  
  14.                     fline = CStr(rs1!LocateDate) & ", " & rs1!Symbol & ", " & CStr(rs1!MarketPrice)
  15.                     Print #fhandle2, fline
  16.                 End If
  17.             End If
  18.             rs1.MoveNext
  19.         Loop
  20.         rs2.MoveNext
  21.     Loop
  22.  
  23.     Close #fhandle1
  24.  
  25. End Function
  26.  
  27.  
Oct 27 '06 #4
Andrew Thackray
76 New Member
From the code snippet it loks like you can do this by creating an SQL statement & setting the report recordsource or the queries command to the SQL

The code would look something like this

[code]

dim SQL as string
dim cMarketPrice as currency

cmarketprice = 5.5
SQL = "Select LocakDate Symbol,MarketPr ice from Table1 inner join Table2 on Table1.Symbol = Table2.Symbol where Table1.MarketPr ice = " & cMarketPrice & " ;"

Reports!"Report Name").recordso urce = sql

[code]

I use this technique of creating SQL in code and setting recordsources etc to the SQL a lot when I want to format data on the fly.

you could include this code in a routine where you pass the market value & create a report/query for that market value
Oct 27 '06 #5
Andrew Thackray
76 New Member
I forgot to mention that if you only want specific records to appear in the report that are selected programmaticall y use the IN keyword and insert the record keys into a list for the IN keyword. The code would look like this

[code]

dim SQL as string
dim Pricelist as string
Dim rsTable1 as recordset
Dim CMarketPrice as currency

rstable1.open

cMarketPrice = AValue You want to test for
Do while not EOF
if rsterable1.Mark etPrice = CMarketPrice then
if len(pricelist) > 0 then pricelist = pricelist & ","
pricelist = pricelist & cmarketprice
endif
rstable1.movene t
loop
rstable1.close
cmarketprice = 5.5
SQL = "Select LocakDate Symbol,MarketPr ice from Table1 inner join Table2 on Table1.Symbol = Table2.Symbol where Table1.MarketPr ice = " & cMarketPrice & " and Record1MarketPr ice IN (: & Pricelist & " ;"

Reports!"Report Name").recordso urce = sql
Oct 27 '06 #6
PEB
1,418 Recognized Expert Top Contributor
Hi,

If you save your data in a temporary table, than you can just use it in your report... It's a solution also!

But there is something better... You can see what you see on your debug window but directly in Report if you paste your code in Open event procedure of the respective report

And instaed to use
debug.print

try with

Me.Print

Or

ReportName.Prin t

Are you seeking for this? :)
Oct 28 '06 #7
ineedahelp
98 New Member
Thank you for the solution of using the OnOpen Event of a report. Just a few questions...I named my report rptLastLSData. when I tried to open the report, I got a error "Variable Not Defined" on the rptLastLSData.p rint line. Also does my report have any recordset defined in the properties of the report? Do I need any fields defined in the report or will it just print out like it does with DEBUG?
thank you for additonal help!
Oct 30 '06 #8
NeoPa
32,569 Recognized Expert Moderator MVP
Also does my report have any recordset defined in the properties of the report?
rptLastLSData has a RecordSource property (Open the Properties page while designing the report and you should see it at the top). In the OnOpen event procedure you can access this via Me.RecordSource . If you set this to a RecordSource here, then it will requery the report with your new Record Source.
Oct 30 '06 #9
PEB
1,418 Recognized Expert Top Contributor
Ok!

Try this code onFormat property in your detail section:

Expand|Select|Wrap|Line Numbers
  1.     Dim rpt As Report
  2.     Dim strMessage As String
  3.     Dim intHorSize As Integer, intVerSize As Integer
  4.  
  5.     Set rpt = Me
  6.     strMessage = "DisplayMessage"
  7.     With rpt
  8.         'Set scale to pixels, and set FontName and
  9.         'FontSize properties.
  10.         .ScaleMode = 3
  11.         .FontName = "Courier"
  12.         .FontSize = 24
  13.     End With
  14.     ' Horizontal width.
  15.     intHorSize = rpt.TextWidth(strMessage)
  16.     ' Vertical height.
  17.     intVerSize = rpt.TextHeight(strMessage)
  18.     ' Calculate location of text to be displayed.
  19.     rpt.CurrentX = (rpt.ScaleWidth / 2) - (intHorSize / 2)
  20.     rpt.CurrentY = (rpt.ScaleHeight / 2) - (intVerSize / 2)
  21.     ' Print text on Report object.
  22.     rpt.Print strMessage
  23.  
  24.  
Oct 31 '06 #10

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

Similar topics

1
1622
by: Cady Steldyn | last post by:
I need to run a data report that will query an Access_Table that has the following Project info: My Form has a command_button with the following code: Private Sub Command1_Click() Set db = New Connection db.CursorLocation = adUseClient db.Open "PROVIDER=MSDataShape;Data
2
6925
by: PeterW | last post by:
I have an xml file from which I want to generate an xsd schema and at a later stage a cs class. The xml file has a mix of defined namespaces and also an empty namespace. These are defined as follows: <silcn:silcn xmlns:silcn='http://silcn.org/200309' xmlns='http://xmlprobe.com/200312'> it contains an element <report> off the root and also a separate <Silcn:report> again off the root.
1
2770
by: Robert Davis | last post by:
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 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...
0
2253
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional assistance. I say additional because I've already had help which is greatly appreciated. I do try to take the time and understand the provided script in hopes on not having to trouble others on those. But here it goes...
1
2319
by: davidbennett | last post by:
Hello, I am new to MS Access. I have created a series of forms that users access to perform data entry. I now need to build in reporting functionality. I would like to create a form that has a drop down box where the user selects a value and then clicks a "generate report" button where data about the selected value is presented in a report. Can someone help get a beginner started on accomplishing this? Thanks,
1
1285
Coldfire
by: Coldfire | last post by:
Problem background: I am developing a windows application (in VisualStudio.Net 2005) that inserts an Institute Info and based on the query I need to generate a report featuring the Detailed Information of Institute. Description I have been trying to use Crystal Reports to generate reports but I dont want Column based report but Paragraph based report. e.g InstituteName: abcd Coursed Offered: List1: asdasdadjhskajhfdkj
6
2639
by: ontherun | last post by:
hi, i am a newbie in access and i created a database which is between client and job. the job fields consists of more than 100 fields. i could not split the fields as the relationship is 1-to1. between client and job, the relationship status is 1-to- many. with large table created, i could enter values from Client form and Job form to the respective tables. so far, everything looks fine. but when i attempt to create a report, i gotta...
3
3876
by: Tarena | last post by:
I have a report that is generated by a query. I have a form with a calendar control. I would like to use the form to force my date range to generate my report. Any suggestions? Do I need to give some more information??? Basically, I would like to set my date range for my report by using a calendar to select the beginning and ending dates.
8
1980
ammoos
by: ammoos | last post by:
Friends .. I want to generate a report in the ASP.NET using C#. from Sybase database. There are two option to generate the report 1) Generate the Report on the Screen itself by using the datagrid 2)Generate PDF report. Displaying the report in the datagrid is easy.. But How can I convert that report to a PDF file…
0
8483
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8603
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6236
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2818
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.