Print the record in the form

G

GS Ghali

I am trying to print just the one record that is being viewed in the form in
report format. The primary key is a text field - "File number".

I have tried to use this code but it doesnt seem to work

Private Sub cmdPrintSummary_Click()
Dim strWhere As String

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[File Number] = " & Me.[File Number]
DoCmd.OpenReport "Case Detail Summary", acViewPreview, , strWhere
End If

End Sub


Does anyone have any ideas? Thanks in advance.
 
A

Allen Browne

If you open your table in design view, what is the data type of your [File
Number] field?

If Number, it should work as you have it.
If Text, you need extra quotes:
strWhere = "[File Number] = """ & Me.[File Number] & """"

Explanation of the quotes in:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html

If that does not solve the issue, be more specific about "doesn't seem to
work." Error message? Report opens with all records? With no records?
 

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