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  

selected criteria from form in report header



 
 
Thread Tools Display Modes
  #1  
Old December 5th, 2009, 08:00 PM posted to microsoft.public.access.reports
lil2009
external usenet poster
 
Posts: 11
Default selected criteria from form in report header

Hi,

After reviewing the many answers to this question, I still can't get the
criteria selected in the list box of a form to show on a report. I added a
textbox to the report and used builder to set the control source to
=[Forms]![frmQBF]![lboData]

Does anyone have an idea why it isn't working?

Thanks.


  #2  
Old December 5th, 2009, 08:08 PM posted to microsoft.public.access.reports
John Spencer
external usenet poster
 
Posts: 7,815
Default selected criteria from form in report header

Is the listbox's Multi Select property set to None? If the property is set to
"simple" or "extended" you cannot get the value of the control.

If the Form is not open, then you should get an error message or a prompt for
the value. The form must be open (it can be visible or not visible) and there
must be somethng selected in lboData in order for a value to be returned.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

lil2009 wrote:
Hi,

After reviewing the many answers to this question, I still can't get the
criteria selected in the list box of a form to show on a report. I added a
textbox to the report and used builder to set the control source to
=[Forms]![frmQBF]![lboData]

Does anyone have an idea why it isn't working?

Thanks.


  #3  
Old December 8th, 2009, 06:50 PM posted to microsoft.public.access.reports
Dale Fye
external usenet poster
 
Posts: 2,651
Default selected criteria from form in report header

Lil,

Whenever I need to get the "value" associated with a listbox that has its
multi-select property set to either "simple" or "extended", I call the
subroutine below.

In your case, it sounds like you have a listbox on your form, and probably a
command button to print or preview the report. Assuming you have the command
button, you would use the click event to open the report and pass the
OpenReport method a criteria string which will limit which records are
visible in your report.

Private Sub cmd_Preview_Click

dim strCriteria as string

strCriteria = "[fieldname] " & fnMultiList(me.listName)
docmd.OpenReport "reportname", acViewPreview,,strCriteria, acDialog

End Sub

You will need to create a standard code module (not tied to a form) and add
the following code to it. This code will concatenate the values of the bound
column of the items that are selected in your listbox. If no items are
selected, it acts as if all items are selected, so if you don't want that
behavior, you will have to modify the code. Otherwise, it will determine how
many items were selected and if it is only 1, will return a string that
starts with an equal sign (=). If multiple items are selected, it will
return a string that include the "IN ( )" clause, with the selected values
wrapped in the ( ).

----
HTH
Dale



"lil2009" wrote:

Hi,

After reviewing the many answers to this question, I still can't get the
criteria selected in the list box of a form to show on a report. I added a
textbox to the report and used builder to set the control source to
=[Forms]![frmQBF]![lboData]

Does anyone have an idea why it isn't working?

Thanks.


 




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


All times are GMT +1. The time now is 08:21 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.