I have a data form which I generated straight from a table. I have been trying to create a button on my form which would print (or print preview) a report of only the current record. I have been researching old posts and have tried to use some of the codes that were given earlier but I can't get any of them to work for me. The following code will open the report but it always goes back to the first record:
Sub
Dim stDocName As String
Dim LinkFilter As String
LinkFilter = "DEMProjectID=" & Me![DEMProjectID]
stDocName = "printrecords"
DoCmd.OpenReport stDocName, acViewPreview, LinkFilter
End Sub
Alternately I have also tried this other code which will open one record but with no data in it-it just shows the labels:
Sub
Dim stDocName As String
DoCmd.OpenReport "printrecords", acViewPreview, , "DEMProjectID =" & Forms![DEM Project Tracking Database]!DEMProjectID
End Sub
There is probably a simple explanation like a syntax error but I can't seem to straighten it out. I have wasted days fooling around with this and any suggestions would be greatly appreciated.
Sub
Dim stDocName As String
Dim LinkFilter As String
LinkFilter = "DEMProjectID=" & Me![DEMProjectID]
stDocName = "printrecords"
DoCmd.OpenReport stDocName, acViewPreview, LinkFilter
End Sub
Alternately I have also tried this other code which will open one record but with no data in it-it just shows the labels:
Sub
Dim stDocName As String
DoCmd.OpenReport "printrecords", acViewPreview, , "DEMProjectID =" & Forms![DEM Project Tracking Database]!DEMProjectID
End Sub
There is probably a simple explanation like a syntax error but I can't seem to straighten it out. I have wasted days fooling around with this and any suggestions would be greatly appreciated.