Printing a report

  • Thread starter Thread starter dogbite via AccessMonster.com
  • Start date Start date
D

dogbite via AccessMonster.com

I have Access 2000 I want to print the current redordset on frmBvistaMain to
rptBvista. I've tryed several of the posts (code) but for some reason I can't
get them to work . I'd like to keep it as simple cause Me.notToSmart=
I'd be grateful for any help.
Thanks
 
I have Access 2000 I want to print the current redordset on frmBvistaMain to
rptBvista. I've tryed several of the posts (code) but for some reason I can't
get them to work . I'd like to keep it as simple cause Me.notToSmart=
I'd be grateful for any help.
Thanks

re: print the current redordset
The current recordset is all of the records in the form.
I suspect you mean the current record.

Your table should have a unique prime key field.
In my example it is named [RecordID].

On the command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "rptBvista", acViewPreview, , "[RecordID] = " &
Me![RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "rptBvista", acViewPreview, ,"[RecordID] = '" &
Me![RecordID] & "'"

For clarity, the single and double quotes are..
"Me![RecordID] = ' " & [RecordID] & " ' "
Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:
Where Clause + Restrict data to a subset of records'
 
fredg said:
I have Access 2000 I want to print the current redordset on frmBvistaMain to
rptBvista. I've tryed several of the posts (code) but for some reason I can't
get them to work . I'd like to keep it as simple cause Me.notToSmart=
I'd be grateful for any help.
Thanks

re: print the current redordset
The current recordset is all of the records in the form.
I suspect you mean the current record.

Your table should have a unique prime key field.
In my example it is named [RecordID].

On the command button's property sheet write
[Event Procedure]
on the Click event line.
Then click on the little button with 3 dots that will appear on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines write:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "rptBvista", acViewPreview, , "[RecordID] = " &
Me![RecordID]

The above assumes a [RecordID] field that is a Number Datatype.

If, however, [RecordID] is Text Datatype, then use:

DoCmd.OpenReport "rptBvista", acViewPreview, ,"[RecordID] = '" &
Me![RecordID] & "'"

For clarity, the single and double quotes are..
"Me![RecordID] = ' " & [RecordID] & " ' "
Change [RecordID] to whatever the actual field name is that you are
using.

See VBA Help files for:

syntax for this is: OpenReport(reportName,[View as acView = acViewNormal],
[WhereCondition])

not sure what you ment by >Where Clause + Restrict data to a subset of
records'
I get a compile error
expected end of statement


in table tblBvista the autoNumber name is RecordId
I allso have a text box on frmbvista that the control source is RecordId
from the table
Not sure I have VBA Help files
But I do have april 2001 MSDN library

IF you give me a little more help THEN
I might get it
Else I can do it with a Quary and a Macro
ElseIf anyone wants to do it with a qry & macro Then
Let me know and I"ll post it for you
end if
Thanks
Dogbite
 
Back
Top