Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2007

Tip: Looking for answers? Try searching our database.

passing a variable to a report

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sbcaco - 29 May 2007 19:45 GMT
hello,

I have a report that shows the detail for 3 different values of a field
named "TransType": (values: pmt, adj, act).

The name, date, and TransType fields are set via a form.  In the report, I
want the detail to show for the chosen TransType(s), name, and date. AND I
want a total of the "ADJ" records for the specified name and date to show in
a field in the footer.  

strDocName = "Sales for 1 month"
Set qdf = dbs.CreateQueryDef("aqdftemp", strSQLComplete)
DoCmd.OpenReport strDocName, acViewPreview  

I am getting the correct data - I just can't figure out how to get the total
for the field type 'adj' in a field in the footer.   I tried this:

   Dim rstRebates As ADODB.Recordset
   Dim strSQLCompleteADJ  As String
   Dim con2 As ADODB.Connection

   strSQLCompleteADJ = "Select sum([amount]) as ADJTotal "
   'to print all Names:
   If Me!chkAllorOne = False Then
       strSQLSalesDate = "having Rebate_Transactons.SalesDate = """ &
Trim(txtSalesDate.Value) & """"
       strSQLCompleteADJ = strSQLCompleteADJ & strSQLFromWhere &
strSQLGroupBy & strSQLSalesDate & strSQLOrderBy
   Else
       'to print one Name:
       strSQLHaving = " HAVING "
       strSQLName = " Rebate_Transactons.Name Like """ &
Trim(lboName.Column(0)) & "*"""
       strSQLTransType = " AND Rebate_Transactons.TransType = ""ADJ"""
       strSQLSalesDate = " AND Rebate_Transactons.SalesDate = """ &
Trim(txtSalesDate.Value) & """"
       strSQLHaving = strSQLHaving & strSQLName & strSQLTransType &
strSQLSalesDate
       strSQLCompleteADJ = strSQLCompleteADJ & strSQLFromWhere &
strSQLGroupBy & strSQLSalesDate & strSQLOrderBy
   End If

   Set rstRebates = New ADODB.Recordset
   rstRebates.Open strSQLCompleteADJ, CurrentProject.Connection
   iADJTotal = rstRebates("ADJTotal")
   Set rstRebates = Nothing

------------------------
I want iADJTotal to be the field in the report.   any suggestions?

another issue:  this report is printed for either all names or one.

thanks a lot!
NetworkTrade - 29 May 2007 23:20 GMT
Here's my ideas:

Q1?   "In the report, I want the detail to show for the chosen TransType(s),
name, and date."

** I would put 3 unbound textboxes in the report and source each one to the
form info
i.e.
=Forms![FormName].[TextBoxName]

of course the Form must be open when the Report opens - so that the Report
can find this info and insert it into the Report txt box.....I use this
technqiue all the time....

Q2? "....AND I want a total of the "ADJ" records for the specified name and
date to show in a field in the footer"

** On this I will admit that I did not review your code....I think an MVP
could do VBA in an event of the Report to count those....while I might take a
more crude approach and count those in a separate query and insert a
subReport with the info because my use of loops is a little rusty.....

Q3? " another issue:  this report is printed for either all names or one. "

** Do not understand this question......

Signature

NTC

> hello,
>
[quoted text clipped - 49 lines]
>
> thanks a lot!
sbcaco - 29 May 2007 23:36 GMT
Q1?   "In the report, I want the detail to show for the chosen TransType(s),
 name, and date."

>>>  I have this covered.  the form calls the report.  or would it be better to have the form open when the report opens?




Q3? " another issue:  this report is printed for either all names or one. "

** Do not understand this question......
>>>  I have a checkbox that says "Check to Print Report for One Name" - if this is not checked, it prints all of the names in the table for that period of time and transtype, if it is checked a listbox appears to allow them to choose a name.  make sense?

thanks!!
NetworkTrade - 30 May 2007 00:29 GMT
>  Q1?   "In the report, I want the detail to show for the chosen TransType(s),
>   name, and date."
>
> >>>  I have this covered.  the form calls the report.  or would it be better to have the form open when the report opens?

*** Right - your form is open...so the report should open and include that
info that was entered into the form's text boxes...this should work fine...no
need to have the form open or anything like that....
>  
>  
>  Q3? " another issue:  this report is printed for either all names or one. "
>  
>  ** Do not understand this question......
> >>>  I have a checkbox that says "Check to Print Report for One Name" - if this is not checked, it prints all of the names in the table for that period of time and transtype, if it is checked a listbox appears to allow them to choose a name.  make sense?

*** The description makes sense.  Is there a question?  perhaps you include
this for completeness - which is ok.....I don't see that this fact has any
change for your first question.

> thanks!!
sbcaco - 30 May 2007 14:57 GMT
*** The description makes sense.  Is there a question?  perhaps you include
this for completeness - which is ok

>>>>>yes, I just put it in there as an fyi...it does add a little complexity to it.  

the most important question I had on this was your 2nd question. anyone have
a solution for me??

thanks.
sbcaco - 31 May 2007 23:28 GMT
figured it out-- I made a UDF in that field and passed the form's parameters
to it.  FoxPro and SQL are so much easier.   :-o
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.