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

Putting variable (Looping) into Report

9
Using Access 2003
I am looping through table values and creating a separate report for each name. The report is then emailed with a TO: and CC: address. That works fine. What I would like to do is put that value (someone's name) in the header of the report. The field containing the name can have up to 5 names in it. I use the LIKE filter to determine if the name is present. The only time the unique name exists is in the loop as it cycles through the existing names. How do I get that fleeting variable into the report as it is opened??
Code:-
Expand|Select|Wrap|Line Numbers
  1. Private Sub Loopy(rs As Recordset)
  2.  
  3. Dim name1, Name2, name3 As String
  4.  
  5. If Not (rs.EOF And rs.BOF) Then
  6.     rs.MoveFirst 
  7.     Do Until rs.EOF = True
  8.      sContactName = rs!WorkCName
  9.  
  10.      ReportHeaderValueDesired = sContactName
  11.  
  12.      name3 = "[qryOpFile]![Resource Total] Like ""*" & sContactName & "*"""
  13.     sContactName = rs!Email1
  14.     Name1 = sContactName
  15.     sContactName = rs!Email2
  16.     Name2 = sContactName
  17.     DoCmd.OpenReport "OpReport", acViewPreview, "", [qryOpFile]![Resource Total] & "Like sContactName, acNormal"
  18.     DoCmd.OpenReport "OpReport", acViewPreview, "", name3, acNormal
  19.     DoCmd.SendObject acReport, "OpReport", "SnapshotFormat(*.snp)", Name1, "Name2", "", sContactName, "", False, ""
  20.     DoCmd.Close acReport, "OpReport"
  21.     rs.MoveNext
  22.     Loop
  23. Else
  24.     MsgBox "There are no records in the recordset."
  25. End If
  26.  
  27. MsgBox "End of staff list"
  28.  
  29. rs.Close 'Close the recordset
  30. Set rs = Nothing 'Clean up
  31. End Sub
Aug 31 '13 #1

✓ answered by Keredw

After much Googling and head scratching, I found the answer and as I suspected, it was VERY simple.

Add the OpenArgs to the end of the doCmd.OpenReport and then in the report, set the Control Source for the Text Box in the Report Header to be =[OpenArgs].
Expand|Select|Wrap|Line Numbers
  1. Name1 = sContactName
  2. DoCmd.OpenReport "OpReport", acViewPreview, "", name3, acNormal, Name1
  3.  
Can I acknowledge the source of the solution I found??
http://windowssecrets.com/forums/sho...Access-2003%29

3 1358
Keredw
9
Sorry. By the way, what are code tags and how do I use them??
Aug 31 '13 #2
Keredw
9
No Need to reply. I am reading your terms of use section. It has all the info I need.
Aug 31 '13 #3
Keredw
9
After much Googling and head scratching, I found the answer and as I suspected, it was VERY simple.

Add the OpenArgs to the end of the doCmd.OpenReport and then in the report, set the Control Source for the Text Box in the Report Header to be =[OpenArgs].
Expand|Select|Wrap|Line Numbers
  1. Name1 = sContactName
  2. DoCmd.OpenReport "OpReport", acViewPreview, "", name3, acNormal, Name1
  3.  
Can I acknowledge the source of the solution I found??
http://windowssecrets.com/forums/sho...Access-2003%29
Sep 1 '13 #4

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

Similar topics

0
by: SalimShahzad | last post by:
dear guruys, can any one put highlights... if i have 2 queries, how one can pass parameter as variable to report/query... i had posted earlier also but no reply... say v have string...
4
by: Trevor Best | last post by:
I have a report that's fairly simple, page headers and footers, detail has a subreport in (can vary in length). The customer wanted a signature block for them, their client and 3rd party. This was...
4
by: lorirobn | last post by:
Hi, I have a main menu that opens several different reports. I am adding an OrderByOn, and currently have it set up for one report with the following statements: !.OrderBy = strOrderBy...
2
by: insideview | last post by:
How do I do something, where var x="-20%"; document.all("something").style.top=x normally, this would work -- document.all("something").style.top='-20%';
13
by: Greg | last post by:
Most suggestions on this topic recommend to use a page footer and make it visible only on the last page. My problem is that the footer is half of the height of a page which means the detail would...
1
by: Intrepid_Yellow | last post by:
Hi, I have the following code that runs my report generator. The user selects a table from a combo box, then whatever fields they want from a list box. (This part all works and the report runs...
1
by: shaiful | last post by:
Hi all, I have a problem with report in vba. I using vba report with access database. my query is: "select name, Roll, Adress from Stdinfo where id=Variable Here from form]" so how i can pass...
11
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
3
by: MAHMAD337 | last post by:
Hi all, I want to declare a global variable in my report (build in oracle report builder). can any one tell what is the procedure to declare a global variable in oracle report builder. bye;
7
by: DThreadgill | last post by:
Don't know if this can be done or not but I'm sure the gurus here will let me know ;) Got a .csv file that is being imported into a table using specs. The table consists of the following: Issue...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.