You did not use the CompanyID field. Instead you used a text field. John
Vinson corrected your code to get it to work, but It still makes more sense
to back up and use the ID (long integer data type) and the code methodology
I showed. Always use an indexed primary key instead of data to do lookups.
It probably doesn't make much difference with a few records, but it does
with thousands, and learning to do it correctly makes it work with
everything.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
"Aamer" <(E-Mail Removed)> wrote in message
news:FDCC91AE-C355-44BA-9DEC-(E-Mail Removed)...
> it did not work
>
> I am selecting company name field name is "pur companyname"
> no its not looking with customer id
> report name is "General Purchase"
>
> I have tried the following:
>
> DoCmd.OpenReport "General Purchase", , , "pur companyname = " & Me.lstpur
> companyname
>
> but its not woking.
> can you pls fix it.
>
> regards
> aamer
>
>
> "Arvin Meyer [MVP]" wrote:
>
>> Hopefully, you should have the ID of Coca Cola in the list box as a bound
>> field. Substituting your names, add a button to the form that opens the
>> report, with the following code:
>>
>> DoCmd.OpenReport "Your Report Name", , , "CompanyID = " & Me.lstCompanyID
>> --
>> Arvin Meyer, MCP, MVP
>> http://www.datastrat.com
>> http://www.mvps.org/access
>> http://www.accessmvp.com
>>
>>
>> "Aamer" <(E-Mail Removed)> wrote in message
>> news:0B8666A8-BC3E-49A3-B13F-(E-Mail Removed)...
>> >I have created a dialog form, on this form I select the company name
>> >from
>> >the
>> > dropdown list.
>> > when a company name is selected, then the report should be generated.
>> >
>> > presently I have a button on the form when i click on it the macro is
>> > set
>> > to
>> > propt the dialog where i have to type the name of the company, if the
>> > company
>> > name is wrong the report opens with no values, if the company name is
>> > right
>> > then I get the report.
>> >
>> > whereas what i want is insted of button I should have the List Box with
>> > company names. Which I have created. But am stuck linking this form
>> > with
>> > the
>> > report Name "General Purchase".
>> >
>> >
>> > e.g. If i select company name "Coca Cola" in the list box it should
>> > give
>> > the
>> > report of coca cola only
>> >
>> >
>> > thanks & merry x-mas to all
>> >
>> > aamer
>>
>>
>> .
>>