Command Button - Access 2003

  • Thread starter Thread starter Denver
  • Start date Start date
D

Denver

Hi,

I have unbound Combo11 with Row Source
SELECT [Name] FROM MSysObjects WHERE [Type]=5 AND [Name] LIKE "wk*"
ORDER BY [Name];

I want that when I click from Combo11 then click on my Combo11 it will
display the report. Like when I click from Combo11 wk25 then I click on
cmdReport it will change the record source of a report name Exception Items
of PMCC2 and display data that are for wk25. Or when I click on wk15 he will
change the record source of a report Name Exception Items of PMMC2 and
display that data that are for wk15 without clicking design view and do
manual changing record source.

is this possible? How would I write my code?
thanks for any help
 
well, first of all, in looking at the MSysObjects table in an A2000 db
written in A2003, it appears that records where Type = 5 are showing the
*RecordSource* of report objects, not the name of report objects. the
records naming report objects appear to have Type = -32764. so if your
intent is to provide your users with a list of reports to choose from, you'd
probably want to change the WHERE clause in the combobox control's
RowSource.

next, from your example, it seems that you've created a separate report for
each week. if that's the case, it's not clear why you need to change the
RecordSource of the report you choose in the combobox control.

is all of the data in a single table? and do you want to report the data the
same way every time, regardless of which week's data you're reporting? if
so, then suggest you create a single report, based on the data table, or
based on a query that is based on the data table. then add code to the
command button's Click event procedure, to call the OpenReport command to
open the report, including criteria in the WHERE Condition argument to
return only the records from the week you want. read up on the OpenReport
Action topic in VBA Help, so you'll understand how the arguments work, and
come back with specific questions.

hth
 
Use the WHERE argument of the OpenReport method:
DoCmd.OpenReport reportname, , , "fieldname='" & comboboxname.Column(x) & "'"
'x' needs to be the column number of the combobox with the value to match,
if the combobox has more than one column and value not in first column (index
of 0).
Place the code in an event, such as the combobox AfterUpdate or button Click.
 
Back
Top