report random query

patatrac

Registered User.
Local time
Today, 12:18
Joined
Jan 17, 2010
Messages
46
ciao for all
i have a query random:

id questions answers
1 xxxx ccccc
2 qqqq vvvvv
3 zzzz fddfdd
4 xxxq fsffsfsf
5 qqqqs gfgggfgfgf

and 2 reports limit 3:
reports questions ( ok with random questions)
reports answer ( my problem where i would visualize the random id+answer displayed of first report). I search in all way but unfortunately without solutions...
thank for help me
 
Could you describe your problem in another way, then I don't get it?
 
the question is simply see the image ...
you look Report1 and Report2 have recordsource Report_print

Report1 have id 35 37 38 51 52
Report2 have id 35 38 39 52 53
how is possible have:

Report1 have id 35 37 38 51 52
Report2 have id 35 37 38 51 52

first open Report1 and after Report2 and have equal id
 

Attachments

  • Cattura.PNG
    Cattura.PNG
    43.2 KB · Views: 174
Show the recordsource for report 1 and report 2.
 
my question is :
query random every open Report1 change my IDs (and this is ok , is random...)
I would that with open Report1 netx step open Report2 and compare in Repor2 equal IDs of Report1
 
i add file
shift button press on open file,

Report_Print the query that is command with random Variabili query
Report1
Report2 (my problem..)

I would open Report1 (questions) and after with Report1 open.... open Report2(answer) with equal id
My solution is
On open event Report1 save in a table IDs , on close delete IDs
but i don't able release it
 

Attachments

Open Report1
report1 have On event open
1 generate a table Answer
2 add id (is this my problem...I would that when I open Report1 in my table Answer INSERT all my display IDs noT only one)

on event close
1 delete table Answer
 

Attachments

sorry i cross posted the questions , i don't think that isn't allow.
Unfortunately don't have solution...
 
I tray to make it: in report1 event on load

Dim db As Database, rst As Recordset, rst2 As Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset("SELECT ID_Body FROM 01_Body ")
Set rst2 = db.OpenRecordset("Answer")
rst.MoveFirst
Me.ID_Body.Value = rst!ID_Body
'Let ID = rst!Unique_ID
Do While Not rst.EOF
rst2.AddNew
rst2("ID_Body").Value = rst("ID_Body").Value
rst2.Update
rst.MoveNext
Loop


rst2.Close
but don't work
I serch the way to capture Me.ID_Body values in my report1
and insert its in the table answer
 
Last edited:
I've made some sample for you in the attached database, open the form "TheReportForm" and click the button.
 

Attachments

wow work!!! great... and many many thanks
if possible explain how its work...

you had create:
1 Report_print (is query create table)
1 TempTableForReports

CODE:

Private Sub OpenReports_Click()

Call DeleteTabel("TempTableForReports")
CurrentDb.Execute "Report_print"

DoCmd.OpenReport "Report1", acViewPreview
DoCmd.OpenReport "Report2", acViewPreview
End Sub
Private Sub DeleteTabel(Table_Name As String)
Dim dbs As Database, ctr As Container, doc As Document

Set dbs = CurrentDb
Set ctr = dbs.Containers!Tables
For Each doc In ctr.Documents
'Slet tabel hvis den eksistere.
If UCase(doc.Name) = Table_Name Then
DoCmd.DeleteObject acTable, doc.Name
Exit For
End If
Next doc
End Sub
 
wow work!!! great... and many many thanks
if possible explain how its work...

you had create:
1 Report_print (is query create table)
1 TempTableForReports
Yes - and set the recordsource for both reports to the created table.
 

Users who are viewing this thread

Back
Top Bottom