populate combo box

krishnanhemanth

Registered User.
Local time
Today, 23:09
Joined
Jun 12, 2009
Messages
115
hi
i have a unbound combo box on a form
how do i add reports to the combo box
i know i can type it using the value list option
but i may have to do it everytime i add a new report

is there another way to automate the process

plz help

krishnanhemanth
 
Create a table and put the names of the reports in there. Then use the table as the rowsource.
 
Here's a routine, assuming you want the combobox to list all reports in the database:

Place a combobox on your form. When the Wizard comes up click on Cancel. Go into the combobox’s Properties

Set Name to ComboReports

Set Row Source Type to Table/Query

In the RowSource box enter this:
Code:
SELECT [MSysObjects].[Name] FROM MsysObjects WHERE (Left$([Name],1)<>"~") And ([MSysObjects].[Type])= 32764 ORDER BY [MSysObjects].[Name];
To open the report selected:

Create a command button. When the Wizard comes up, click on Cancel. Go into the button’s Properties.

Name the button PrintReport

For the button’s OnClick event use this code:
Code:
Private Sub PrintReport_Click()
   If Not IsNull(ComboReports) And ComboReports <> "" Then
     DoCmd.OpenReport ComboReports, acViewPreview  ' use acNormal to print without preview
   Else
     MsgBox ("You Must First Select a Report To Print!")
     ComboReports.SetFocus
   End If
   ComboReports = ""
End Sub
You should now be set! Select a report and click Print.

Linq ;0)>
 
The only problem I have in using the MySysObjects table is that the name that appears in the combo box is the name that it is stored as in Access. This name may not be obviously identyfiable to the user. This is why I create a table with the Access name and the meaningful name. Let the user choose from the meaningful names but have the Access name as the bound column and refer to it as described in the previous post.
 
thank you both for your valuable time and idea

the table idea is working------reports are visible in the combo

but

the missinglinq idea...iam not able to get it work.... the combobox is not showing any value

krishnanhemanth
 
hi

I have got it working to some extent ...that is..

the reports are avilable in the combo box
the selected report can be printed using the print button

i have attatched a image....

what i want is...
to filter the report based on the date selection i make

krishnanhemanth
 

Attachments

  • PRINT.jpg
    PRINT.jpg
    88.4 KB · Views: 110
Add a where condition to the reports underlying record source

Between TxtDateLower And TxtDateUpper
 
i put he condition like this

between [upperdate] and [lowerdate] in the query

but no results
 
Sorry, krishnanhemanth! There should have been a negative sign in from of the object type for reports.

([MSysObjects].[Type])= 32764

should have been

([MSysObjects].[Type])= -32764

For some bizarre reason when copying stuff from MS Word (which is where I keep my boilerplate code) to some of the forums the negative or minus sign is removed. But glad you've got something working, at any rate!

David: That's why I make it a practice to give my forms/reports/queries names that make sense to everyone! Then, when a past client calls, wanting to modify a certain report, from an app I did 5 years ago, I know what's he's talking about! It kind of is in the same vein as documenting things clearly! My cranial 'hard drive' is so stuffed with data, at my advanced age, that I need to keep things as simple as possible when retrieving something!

Linq
 
Some members disagree with this solution but take a look at this thread to see how to get it to work.
 
thankyou missinglinq

you people out here are of great help

thanks all of you

stage 1 is over

now stuck with stage 2
 
ML

I take your point but having a list such as

RptYTDActivity
RptActualVersusForecastByProductGroup
RptThisThatAnTheOther

Is not very pleasing to the eye

Whereas

Activity Year-To-Date
Forecasted against Actuals by product group
Another friendly report name

is more professional looking.
 

Users who are viewing this thread

Back
Top Bottom