Printing a single records report from a continuous form

Sam Summers

Registered User.
Local time
Today, 00:20
Joined
Sep 17, 2001
Messages
939
I've been trying to get my head round this one , but i'm just to thick to get it.

I have a continuous form that lists all items at a certain location.
The user selects a record by clicking on the record selector and then clicks on a command button with this code:

stDocName = "DivingInspectionCert"
stLinkCriteria = ("EquipmentID = " & Me!EquipmentID)
DoCmd.OpenForm stDocName, , , stLinkCriteria

The user then enters inspection details in to the "DivingInspectionCert" form which i want to store in a table (DivingCert) which will relate to the item. On completion of this form the user then clicks on a command button with this code:

DoCmd.RunCommand acCmdSaveRecord

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "There are no items to Print", vbInformation, "EquiTrac"
End
Else
DoCmd.OpenReport "DivingInspectionRpt", , , ("EquipmentID = " & Me!EquipmentID)
DoCmd.Close

When i click on this button, the report doesn't print and i get a message "No current record".
The inspection details are not stored in the table.
I did have the forms RecordSource based on the table "DivingCert" but that didn't work and i have just tried a query but it is still not working.

Would be much appreciated if you can help me.
Thank you
 
Try using the full name of the control including the form name instead of using the Me shorthand.
 
Tried that all the way through and still get the message "No current record" and no report printed.
Maybe i should use an append query first and then attempt to print?
 
Hi Sam

One thing that I did notice in your code is that there are no [...] around the field names in the criteria. My forms work with Me!, but if you have problems, put the the full references, as per Neil's suggestion and see how you go...

Regards
Rod

Examples:
stLinkCriteria = ("[EquipmentID] = " & Forms!<FormName>![EquipmentID])
DoCmd.OpenReport "DivingInspectionRpt", , , ("[EquipmentID] = " & Forms!<FormName>![EquipmentID])
 

Users who are viewing this thread

Back
Top Bottom