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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top