A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Form to generate a Report code



 
 
Thread Tools Display Modes
  #1  
Old July 13th, 2004, 12:42 AM
Pat Coleman
external usenet poster
 
Posts: n/a
Default Form to generate a Report code

Newbie Form / Report using code Question

I am tring to generate a form with two combo boxes, using a 'Value List' as
the source type and manually entered values as the row source.
I also want a button called Preview which when pressed will preview a report
( called report01 ) based on the selection in the two combo boxes.

I want to stick to CODE only , as opposed to writing a query or using a
macro

So Far I have

Cmb01 will have 3 values "Distribuor"; "Wholesale"; "Retail"

Cmb02 will have 3 values "EastCoast" " MidWest" "WestCoast"

And the preview button.

The report - report01, is pulled from a customer table which includes two
fields called
1) 'Type' which is either Distributor, Wholesale or Retail.
2) 'Area' which is either EastCoast, MidWest or WestCoast

The question are

1. What is the code, if any is required, for the combo boxes to capture the
choice of values picked by the user and where to I paste this code in the
combo box.

2. What would be the corresponding code for the preview button to capture
the values of the Combo Box and pass it through to the Report.
I assume I paste this code in the 'OnClick' field of the Event Tab in the
properties of the Preview button.

I am thinking the preview code will be something like
DoCmd.OpenReport "report01", acPreview, "[Type] = Cmb01 AND [Area] =
Cmb02"

I know the above line of code has errors in it but I cant figure out the
right code for my little project.

Any help appreciated.


  #2  
Old July 13th, 2004, 03:04 AM
Marshall Barton
external usenet poster
 
Posts: n/a
Default Form to generate a Report code

Pat Coleman wrote:

Newbie Form / Report using code Question

I am tring to generate a form with two combo boxes, using a 'Value List' as
the source type and manually entered values as the row source.
I also want a button called Preview which when pressed will preview a report
( called report01 ) based on the selection in the two combo boxes.

I want to stick to CODE only , as opposed to writing a query or using a
macro

So Far I have

Cmb01 will have 3 values "Distribuor"; "Wholesale"; "Retail"

Cmb02 will have 3 values "EastCoast" " MidWest" "WestCoast"

And the preview button.

The report - report01, is pulled from a customer table which includes two
fields called
1) 'Type' which is either Distributor, Wholesale or Retail.
2) 'Area' which is either EastCoast, MidWest or WestCoast

The question are

1. What is the code, if any is required, for the combo boxes to capture the
choice of values picked by the user and where to I paste this code in the
combo box.


None needed.


2. What would be the corresponding code for the preview button to capture
the values of the Combo Box and pass it through to the Report.
I assume I paste this code in the 'OnClick' field of the Event Tab in the
properties of the Preview button.


See Below.


I am thinking the preview code will be something like
DoCmd.OpenReport "report01", acPreview, "[Type] = Cmb01 AND [Area] =
Cmb02"


Close, but you need to get the value of the combo boxes, not
their names, and the values must end up in quotes:

DoCmd.OpenReport "report01", acPreview, _
"[Type] = '" & Cmb01 & "' AND [Area] = "' & Cmb02 & "'"


--
Marsh
MVP [MS Access]
  #3  
Old July 14th, 2004, 11:55 PM
Pat Coleman
external usenet poster
 
Posts: n/a
Default Form to generate a Report code

Tried to insert the following code in to the OnClick event of the preview
button and it opens the report but does not filter it whatsoever - like it
is ignoring the two values.

Dim stDocName As String

stDocName = "Statement"
DoCmd.OpenReport stDocName, acPreview, "[Text2] = '" & Cmb01 & "' AND
[Text3] = '" & Cmb02 & "' "


Where is the error ???


"Marshall Barton" wrote in message
...
Pat Coleman wrote:

Newbie Form / Report using code Question

I am tring to generate a form with two combo boxes, using a 'Value List'

as
the source type and manually entered values as the row source.
I also want a button called Preview which when pressed will preview a

report
( called report01 ) based on the selection in the two combo boxes.

I want to stick to CODE only , as opposed to writing a query or using a
macro

So Far I have

Cmb01 will have 3 values "Distribuor"; "Wholesale"; "Retail"

Cmb02 will have 3 values "EastCoast" " MidWest" "WestCoast"

And the preview button.

The report - report01, is pulled from a customer table which includes two
fields called
1) 'Type' which is either Distributor, Wholesale or Retail.
2) 'Area' which is either EastCoast, MidWest or WestCoast

The question are

1. What is the code, if any is required, for the combo boxes to capture

the
choice of values picked by the user and where to I paste this code in the
combo box.


None needed.


2. What would be the corresponding code for the preview button to capture
the values of the Combo Box and pass it through to the Report.
I assume I paste this code in the 'OnClick' field of the Event Tab in the
properties of the Preview button.


See Below.


I am thinking the preview code will be something like
DoCmd.OpenReport "report01", acPreview, "[Type] = Cmb01 AND [Area] =
Cmb02"


Close, but you need to get the value of the combo boxes, not
their names, and the values must end up in quotes:

DoCmd.OpenReport "report01", acPreview, _
"[Type] = '" & Cmb01 & "' AND [Area] = "' & Cmb02 & "'"


--
Marsh
MVP [MS Access]



  #4  
Old July 15th, 2004, 02:00 AM
Marshall Barton
external usenet poster
 
Posts: n/a
Default Form to generate a Report code

Pat Coleman wrote:

Tried to insert the following code in to the OnClick event of the preview
button and it opens the report but does not filter it whatsoever - like it
is ignoring the two values.

Dim stDocName As String

stDocName = "Statement"
DoCmd.OpenReport stDocName, acPreview, "[Text2] = '" & Cmb01 & "' AND
[Text3] = '" & Cmb02 & "' "



You're missing a comma:

DoCmd.OpenReport stDocName, acPreview, , "[Text2] = . . .

Where did Text1 and Text2 come from? I thought you said the
names of the fields (in the table/query) were named Type and
Area??
--
Marsh
MVP [MS Access]




"Marshall Barton" wrote
Pat Coleman wrote:

Newbie Form / Report using code Question

I am tring to generate a form with two combo boxes, using a 'Value List'

as
the source type and manually entered values as the row source.
I also want a button called Preview which when pressed will preview a

report
( called report01 ) based on the selection in the two combo boxes.

I want to stick to CODE only , as opposed to writing a query or using a
macro

So Far I have

Cmb01 will have 3 values "Distribuor"; "Wholesale"; "Retail"

Cmb02 will have 3 values "EastCoast" " MidWest" "WestCoast"

And the preview button.

The report - report01, is pulled from a customer table which includes two
fields called
1) 'Type' which is either Distributor, Wholesale or Retail.
2) 'Area' which is either EastCoast, MidWest or WestCoast

The question are

1. What is the code, if any is required, for the combo boxes to capture

the
choice of values picked by the user and where to I paste this code in the
combo box.


None needed.


2. What would be the corresponding code for the preview button to capture
the values of the Combo Box and pass it through to the Report.
I assume I paste this code in the 'OnClick' field of the Event Tab in the
properties of the Preview button.


See Below.


I am thinking the preview code will be something like
DoCmd.OpenReport "report01", acPreview, "[Type] = Cmb01 AND [Area] =
Cmb02"


Close, but you need to get the value of the combo boxes, not
their names, and the values must end up in quotes:

DoCmd.OpenReport "report01", acPreview, _
"[Type] = '" & Cmb01 & "' AND [Area] = "' & Cmb02 & "'"


  #5  
Old July 16th, 2004, 12:58 PM
Pat Coleman
external usenet poster
 
Posts: n/a
Default Form to generate a Report code

Thank you for your help, it works fine now.

The Text2 and Text3 were just renaming of the fields in the main customer
table.

Back in business now.

Pat
"Marshall Barton" wrote in message
...
Pat Coleman wrote:

Tried to insert the following code in to the OnClick event of the preview
button and it opens the report but does not filter it whatsoever - like

it
is ignoring the two values.

Dim stDocName As String

stDocName = "Statement"
DoCmd.OpenReport stDocName, acPreview, "[Text2] = '" & Cmb01 & "' AND
[Text3] = '" & Cmb02 & "' "



You're missing a comma:

DoCmd.OpenReport stDocName, acPreview, , "[Text2] = . . .

Where did Text1 and Text2 come from? I thought you said the
names of the fields (in the table/query) were named Type and
Area??
--
Marsh
MVP [MS Access]




"Marshall Barton" wrote
Pat Coleman wrote:

Newbie Form / Report using code Question

I am tring to generate a form with two combo boxes, using a 'Value

List'
as
the source type and manually entered values as the row source.
I also want a button called Preview which when pressed will preview a

report
( called report01 ) based on the selection in the two combo boxes.

I want to stick to CODE only , as opposed to writing a query or using

a
macro

So Far I have

Cmb01 will have 3 values "Distribuor"; "Wholesale"; "Retail"

Cmb02 will have 3 values "EastCoast" " MidWest" "WestCoast"

And the preview button.

The report - report01, is pulled from a customer table which includes

two
fields called
1) 'Type' which is either Distributor, Wholesale or Retail.
2) 'Area' which is either EastCoast, MidWest or WestCoast

The question are

1. What is the code, if any is required, for the combo boxes to

capture
the
choice of values picked by the user and where to I paste this code in

the
combo box.

None needed.


2. What would be the corresponding code for the preview button to

capture
the values of the Combo Box and pass it through to the Report.
I assume I paste this code in the 'OnClick' field of the Event Tab in

the
properties of the Preview button.

See Below.


I am thinking the preview code will be something like
DoCmd.OpenReport "report01", acPreview, "[Type] = Cmb01 AND

[Area] =
Cmb02"

Close, but you need to get the value of the combo boxes, not
their names, and the values must end up in quotes:

DoCmd.OpenReport "report01", acPreview, _
"[Type] = '" & Cmb01 & "' AND [Area] = "' & Cmb02 & "'"




 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
6 Tables, 1 Report, W/O 6 Qrys Andy Setting Up & Running Reports 9 June 29th, 2004 09:52 PM
How to show image in the form or report? JJ General Discussion 1 June 29th, 2004 06:01 AM
Creating a report from a form Kristin Setting Up & Running Reports 7 June 28th, 2004 09:21 PM
I AM SO DUMB..........................PLEASE HELP kdc New Users 23 June 2nd, 2004 07:15 PM


All times are GMT +1. The time now is 01:20 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.