Sorry to bother again. I tried this in my code and it gives me error
messages. The overall code is as follows (my three fields that combine to
make the primary key are file_number, record_number and request_number - they
are all numerical):
Private Sub Command35_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 = "FirstField = " & Me.file_number &" "&_
"AND SecondField = " & Me.record_number&" "&_
"AND ThirdField = " & Me.request_number
DoCmd.OpenReport "RequestCNRs", acViewPreview, , strWhere
End If
End Sub
Slappy said:
Thank you very much!
Tim Ferguson said:
strWhere = "[ID] = " & Me.[ID]
My problem is that I have to substitute the name of my primary key for
"ID" in the above code but my primary key is three combined fields. I
don't know how to write that into the code.
strWhere = "FirstField = " & Me.TextBox1 & " " & _
"AND SecondField = " & Me.TextBox2 & " " & _
"AND ThirdField = " & Me.TextBox3
If the values are not all numeric, then remember to put the appropriate
quotes or date formats around them.
Hope that helps
Tim F