create a report using vba to select the names for the report

  • Thread starter trevorC via AccessMonster.com
  • Start date
T

trevorC via AccessMonster.com

Hi,
I need to create a report of selected Customers, I have gone as far as
creating a string with customer names in it. Whats next?

sample =

Selected_Customer_Names= [ABC], [test], [New], [A New One] ...... and so on.

Is this correct for the report and/or how do i open the report with the above
only listed?
 
J

John W. Vinson

Hi,
I need to create a report of selected Customers, I have gone as far as
creating a string with customer names in it. Whats next?

sample =

Selected_Customer_Names= [ABC], [test], [New], [A New One] ...... and so on.

Is this correct for the report and/or how do i open the report with the above
only listed?

square brackets delimit field or control names. This list won't do what you
want. If you have customers ABC, Test, New and so on; and these names are
unique (names rarely are, I know three guys named Fred Brown), then you could
use a string with the names in doublquotes:

"ABC", "test", "New", "A New One"

and use this string in the WhereCondition argument of the OpenReport action:

DoCmd.OpenReport "MyReport", WhereCondition := "[CustomerName] IN (" _
& Selected_Customer_Names & ")"

But I suspect there are better ways to go about it if you would care to post
some information about your table structures and the context in which you're
doing this.
 
Top