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
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.
Am I let with just writing them to a temporary table and then using this table as the recordset of my report?
MMcCarthy 14,534
Recognized Expert Moderator MVP
You need something like this: -
-
Public Function writeTextFile()
-
Dim fhandle1 As Integer
-
Dim fline As String
-
'open the text file to be written to
-
fhandle1 = FreeFile
-
Open "Full path to text File" For Output Access Write As #fhandle1
-
-
Do Until rs2.EOF
-
Do Until rs1.EOF
-
If rs2!Symbol = rs1!Symbol Then
-
If rs1!MarketPrice <> -5.25 Then
-
-
fline = CStr(rs1!LocateDate) & ", " & rs1!Symbol & ", " & CStr(rs1!MarketPrice)
-
Print #fhandle2, fline
-
End If
-
End If
-
rs1.MoveNext
-
Loop
-
rs2.MoveNext
-
Loop
-
-
Close #fhandle1
-
-
End Function
-
-
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
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
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? :)
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!
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.
PEB 1,418
Recognized Expert Top Contributor
Ok!
Try this code onFormat property in your detail section: -
Dim rpt As Report
-
Dim strMessage As String
-
Dim intHorSize As Integer, intVerSize As Integer
-
-
Set rpt = Me
-
strMessage = "DisplayMessage"
-
With rpt
-
'Set scale to pixels, and set FontName and
-
'FontSize properties.
-
.ScaleMode = 3
-
.FontName = "Courier"
-
.FontSize = 24
-
End With
-
' Horizontal width.
-
intHorSize = rpt.TextWidth(strMessage)
-
' Vertical height.
-
intVerSize = rpt.TextHeight(strMessage)
-
' Calculate location of text to be displayed.
-
rpt.CurrentX = (rpt.ScaleWidth / 2) - (intHorSize / 2)
-
rpt.CurrentY = (rpt.ScaleHeight / 2) - (intVerSize / 2)
-
' Print text on Report object.
-
rpt.Print strMessage
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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.
|
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...
|
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...
|
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,
| |
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
|
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...
|
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.
|
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…
|
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...
|
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,...
| |
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,...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |