Print current form record


C

christie peterson

I have been trying to get my command button to print a report showing only the current record on the form. I have searched this and other forums and found some answers but none have worked for me.

I'm not a programmer but have usually just used macros and queries to 'get it done'. I will list the two things I tried.. both failed.

One was using query with the below setup:
Field: tbl Root Cause.* | ID
Table: tbl Root Cause | tbl Root Cause
Criteria: | [Forms]![frmRoot Cause]|[ID]

This query returns a blank record.

the next was to Program the command button with an OnClick Event which read as follows

DoCmd.OpenReport "rpt Root Cause Form",acViewPreview
Reports![rpt Root Cause Form].Filter = "ID" = "&Me[ID]"
Reports![rpt Root Cause Form].FilterOn = True

This returns a debugging error

Any other suggestions?



EggHeadCafe - Software Developer Portal of Choice
WPF And The Model View View Model Pattern
http://www.eggheadcafe.com/tutorial...b-7374d3da3425/wpf-and-the-model-view-vi.aspx
 
Ad

Advertisements

D

Damon Heron

Your query should look something like this:

Select tblRootCause.ID, tblRootCause.[YourFieldName],
tblRootCause.[otherfieldnames] WHERE tblRootCause.ID = [forms]![Name of your
form]![Name of field with the ID #];

With the command button on the form, and the above query as the source of
the report.
To test, first type the query and run it (with form closed) - it should ask
for the parameter if your syntax is correct...

Damon
 
Ad

Advertisements

F

fredg

I have been trying to get my command button to print a report
showing only the current record on the form. I have searched this
and other forums and found some answers but none have worked for
me.

I'm not a programmer but have usually just used macros and queries
to 'get it done'. I will list the two things I tried.. both
failed.

One was using query with the below setup:
Field: tbl Root Cause.* | ID
Table: tbl Root Cause | tbl Root Cause
Criteria: | [Forms]![frmRoot Cause]|[ID]

This query returns a blank record.

the next was to Program the command button with an OnClick Event which read as follows

DoCmd.OpenReport "rpt Root Cause Form",acViewPreview
Reports![rpt Root Cause Form].Filter = "ID" = "&Me[ID]"
Reports![rpt Root Cause Form].FilterOn = True

This returns a debugging error

Any other suggestions?

EggHeadCafe - Software Developer Portal of Choice
WPF And The Model View View Model Pattern
http://www.eggheadcafe.com/tutorial...b-7374d3da3425/wpf-and-the-model-view-vi.aspx


Don't forget to use spaces and the dot or bang to separate the
different parts of the syntax,
i.e. your "ID" = "&Me[ID]" should have been "ID = " & Me![ID]"

1) You can remove the criteria from the query and let the query return
all records.

2) Look up the OpenReport method in VBA help and read about the
various arguments this method can use.

3) Then use the where clause argument of the OpenReport method.

If [ID] is a Number datatype field, then:

DoCmd.OpenReport "rpt Root Cause Form", acViewPreview, , "[ID] = " &
Me.[ID]

If [ID] is a Text datatype field, then use:

DoCmd.OpenReport "rpt Root Cause Form", acViewPreview, , "[ID] = '" &
Me.[ID] & "'"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top