Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA for report

Status
Not open for further replies.

Spiderdan1016

Technical User
Aug 30, 2004
13
0
0
US
I have a report that i run every morning. The report breaksdown the sales for the day by username and type of sale. each sale can also be either an order,type O, credit, type C, or return, type R. I need to add some VBA to the report that when a line is a type C or type R the qty shipped and price is multiplied by -1 to make it negative. any ideas. i have experience in programming just havent used VBA in so long forgot the syntax
 
or if its easier the report is made off of a table. if there is an easier way of writing something to go through the table and set the values to negatives in the table before the report is even run that would work as well.
 
Hi,

If the report is form a table, why not use MS Query to gen the report. The calculation can either be done in the query or in a column adjacent to the resultset. There is a switch in Edit/Data Range Parameters, to copy formula in adjacent column(s).

Skip,
[sub]
[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue][/sub]

 
i'm not sure i understand. I highly customized the report will creating it with ms query keep the same customizations? and then what will i put in the edit/date range paramaters if type c make negative?
 


Then just add a column for a NEW Price
[tt]
=If(Or(Type="C",Type="R"),-1,1)*Price
[/tt]
I'm using Names for cell references for clarity.

Skip,
[sub]
[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue][/sub]

 
everytime i type it in it says its missing a comma...

=If((Or([SATYPE]="C",[SATYPE]="R"),-1,1)*[# Shipped])

am i missing something. satype is the field name for the types. and i need to multiply it for Qty SHipped and Price.
 

parenthesis in wrong place...
[tt]
=If(Or([SATYPE]="C",[SATYPE]="R"),-1,1)*[# Shipped]
[/tt]
If this is in a query...
[tt]
=IIf(Or([SATYPE]="C",[SATYPE]="R"),-1,1)*[# Shipped]
[/tt]



Skip,
[sub]
[glasses] [red]Be advised:[/red] When you ignite a firecracker in a bowl of vanilla, chocolate & strawberry ice cream, you get...
Neopolitan Blownapart! [tongue][/sub]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top