PC Review


Reply
Thread Tools Rate Thread

Dialog form Linked To Report

 
 
Aamer
Guest
Posts: n/a
 
      25th Dec 2009
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
 
Reply With Quote
 
 
 
 
Arvin Meyer [MVP]
Guest
Posts: n/a
 
      25th Dec 2009
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



 
Reply With Quote
 
Aamer
Guest
Posts: n/a
 
      25th Dec 2009
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

>
>
> .
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      25th Dec 2009
On Fri, 25 Dec 2009 10:38:01 -0800, Aamer <(E-Mail Removed)>
wrote:

>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.


Two problems that I see: for one, you (unwisely) used a blank in the
fieldname. If you use blanks or other special characters in fieldnames you
must enclose the fieldname in square brackets. In addition, if you're
searching for a text company name, you must include the syntactically required
quotemarks. Since a company name might contain an apostrophe (Joe's Diner for
example) you must delimit with doublequotes; to include a doublequote in a
string delimited with doublequotes, you must use TWO doublequotes. Try

DoCmd.OpenReport "General Purchase", , , "[pur companyname] = """ _
& Me.[lstpur companyname] & """"

--

John W. Vinson [MVP]
 
Reply With Quote
 
Arvin Meyer [MVP]
Guest
Posts: n/a
 
      25th Dec 2009
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

>>
>>
>> .
>>



 
Reply With Quote
 
Aamer
Guest
Posts: n/a
 
      26th Dec 2009
I have No idea why this code is still not working.

let me explain what I did

1. Created a popup form "Dialog General Purchase"
2. Placed a List Box which collects the Company Names from "General Purchase
Detail Querry" The feild for Company name is "Pur CompanyName" Grouped them
so they are not duplicated.
3. Placed a Button on the "Dialog General Purchase" Form
4. in the properties of the button on clik i cliked on CODE BUILDER and
entered the following code.

DoCmd.OpenReport "General Purchase Detail", , , "[pur companyname] = """ _
& Me.[lstpur companyname] & """"

after i do the above it still gives me error.



"John W. Vinson" wrote:

> On Fri, 25 Dec 2009 10:38:01 -0800, Aamer <(E-Mail Removed)>
> wrote:
>
> >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.

>
> Two problems that I see: for one, you (unwisely) used a blank in the
> fieldname. If you use blanks or other special characters in fieldnames you
> must enclose the fieldname in square brackets. In addition, if you're
> searching for a text company name, you must include the syntactically required
> quotemarks. Since a company name might contain an apostrophe (Joe's Diner for
> example) you must delimit with doublequotes; to include a doublequote in a
> string delimited with doublequotes, you must use TWO doublequotes. Try
>
> DoCmd.OpenReport "General Purchase", , , "[pur companyname] = """ _
> & Me.[lstpur companyname] & """"
>
> --
>
> John W. Vinson [MVP]
> .
>

 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      26th Dec 2009
On Fri, 25 Dec 2009 18:42:01 -0800, Aamer <(E-Mail Removed)>
wrote:

>I have No idea why this code is still not working.
>
>let me explain what I did
>
>1. Created a popup form "Dialog General Purchase"
>2. Placed a List Box which collects the Company Names from "General Purchase
>Detail Querry" The feild for Company name is "Pur CompanyName" Grouped them
>so they are not duplicated.
>3. Placed a Button on the "Dialog General Purchase" Form
>4. in the properties of the button on clik i cliked on CODE BUILDER and
>entered the following code.
>
>DoCmd.OpenReport "General Purchase Detail", , , "[pur companyname] = """ _
>& Me.[lstpur companyname] & """"
>
>after i do the above it still gives me error.


I'm in full agreement with Arvin that you should *not* use the company name as
the linking field. Company names change, and can duplicate other companies'
names. You really should follow his good advice and use a unique meaningless
numeric ID as the company ID (behind the scenes, not shown to users).

Without seeing the Recordsource and Bound Column properties of the listbox
[lstpur companyname] and knowing more about the tables (e.g. is [pur
companyname] a Lookup field?) it's hard to advise... but I'd listen to Arvin
if I were you!
--

John W. Vinson [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dialog Form for filtering report oldblindpew Microsoft Access Reports 5 25th Feb 2010 06:43 PM
Problem With Dialog Form Linked To Generate Report Aamer Microsoft Access 8 31st Dec 2009 03:37 AM
Adding Report Field linked to a Form =?Utf-8?B?cmljc2Vi?= Microsoft Access Reports 4 24th Apr 2007 04:16 AM
report linked to query by form cmichaud@ufl.edu Microsoft Access Reports 3 8th Apr 2006 04:03 AM
Parameter thru Form Dialog Box for REPORT =?Utf-8?B?U2FuZHk=?= Microsoft Access Reports 16 10th Jan 2006 10:06 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:00 AM.