Print Current record....

W

W1bbleMe

Hi all.
I posted this question in one of the other Access groups and no one seemed
to be able to help as I recieved no replies. I have sorted out the Print
current record (with another members excellent advice) other than I forgot
that the record that can be synced can have a duplicate associated record

i.e. We run various courses which are "unique" ...1902, 1900, 1802. But
they have associated Course Entry's which are also unquie. i.e Course No:
1902 could have a course Entry of 66. The trouble is other courses can also
have a course Entry of 66.

Course 1900 Entry 66
Course 1802 Entry 66

The Entry is the Entry number for the course (good english??)

The Code is:

DoCmd.OpenReport "RptNominalRole2", acPrintPreview, , "CourseNo = '" &
Me.CourseNo & "'"

I have tried using the the 'and' after the above statement to include the
field
"CrseEntry" so that the report syncs to both values on the open form i.e.

"CourseNo" and the" CrseEntry"....This would then ensure that the print only
prints those records unique to both criteria.

I hope that I have explained this ok and really hope that there is a
solution to my problem.

with Thanks

David
 
J

John Spencer

It would help if you showed what you tried and failed, but try

DoCmd.OpenReport "RptNominalRole2", acPrintPreview, , "CourseNo = '" &
Me.CourseNo & "' AND CrseEntry = '" & Me.CrseEntry & "' "

Note that the AND is enclosed within the quote marks. The usual error
is to put the AND outside the quote marks. You are building a where
clause without the word WHERE at the start of the clause.

A good way to troubleshoot this process is to use a string to build the
criteria and then debug.print the string

Dim strWhere as String
StrWhere = "CourseNo = '" & Me.CourseNo & "' AND CrseEntry = '" &
Me.CrseEntry & "' "

'Remove the next two lines after you are satisfied that the string
'appears to be correct
debug.print strWhere
STOP

'Preview the report
DoCmd.OpenReport "RptNominalRole2", acPrintPreview, , strWhere


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
W

W1bbleMe

Hi,

The amended code works really well!. Where I failed was indeed in not
enclosing the AND in the statement and, as you rightly say, I really should
have remembered that I was building a WHERE clause. Tunnel vision I think.

Many many thanks John, and really appreciate your assistance in this.

with best wishes,

David Richardson
 

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