darthcalis
Registered User.
- Local time
- Today, 18:25
- Joined
- Mar 20, 2012
- Messages
- 17
Hi all,
I have some ongoing problems with getting a report to 'work' with a single record. So far I have 3 issues; displaying a single record, printing a single record, and outputing a single record to a PDF file.
The report itself is a report of customer and supplier contracts based on data in multiple tables, and I only want to print/view/output a single contract at a time. I have a query which pulls all the required data into one place. The report launches from a command button I have in a form which is displaying the record I currently want to work with. The name of the form is stored in a constant called 'const_rptContractReport', and the ID of the record I want is stored in a field called '[CONTRACT_ID]'.
Regarding viewing, I initially tried this:
DoCmd.OpenReport const_rptContractReport, acViewPreview, , "[CONTRACT_ID] = " & Me!CONTRACT_ID.value
It's my understanding that this should work, but it was inconsistent. Sometimes it would open the correct record, but sometimes it would open the first record in the query. There seemed to be no logical reason for it. I tried printing out the contract ID and indeed it was the case that sometimes the ID was correct, and sometimes it wasn't, even though the same record was always being displayed. Not getting very far, I switched to this:
DoCmd.OpenReport const_rptContractReport, acViewPreview, , "[CONTRACT_ID] = " & Forms(const_frmContractBuilderForm)!CONTRACT_ID.value
This seems to work consistently (at least for now!), so not really understanding what was going on there. Even weirder, if I want to print the record I use this:
DoCmd.OpenReport const_rptContractReport, acViewNormal, , "[CONTRACT_ID] = " & Forms(const_frmContractBuilderForm)!CONTRACT_ID.value
This prints the record, but all my unbound fields turn up empty when printed! I think I may be missing something obvious with the printing due to my lack of experience with 2010, as it is just the unbound fields that don't print.
Finally, is there anyway to output a single record to a PDF? I've checked out the OutputTo method, but as far as I can work out this dumps the entire report. It would be so convenient if this could be limited to a single record. Is there any way to do this? I'm thinking that I may have to create a query that will pull out only the single record that I want and use that as the report source. Would this be the best way, or is there a simple command that I'm missing.
Sorry for the long winded post, especially as it's my first technical post on this forum. Any help would be much appreciated.
I have some ongoing problems with getting a report to 'work' with a single record. So far I have 3 issues; displaying a single record, printing a single record, and outputing a single record to a PDF file.
The report itself is a report of customer and supplier contracts based on data in multiple tables, and I only want to print/view/output a single contract at a time. I have a query which pulls all the required data into one place. The report launches from a command button I have in a form which is displaying the record I currently want to work with. The name of the form is stored in a constant called 'const_rptContractReport', and the ID of the record I want is stored in a field called '[CONTRACT_ID]'.
Regarding viewing, I initially tried this:
DoCmd.OpenReport const_rptContractReport, acViewPreview, , "[CONTRACT_ID] = " & Me!CONTRACT_ID.value
It's my understanding that this should work, but it was inconsistent. Sometimes it would open the correct record, but sometimes it would open the first record in the query. There seemed to be no logical reason for it. I tried printing out the contract ID and indeed it was the case that sometimes the ID was correct, and sometimes it wasn't, even though the same record was always being displayed. Not getting very far, I switched to this:
DoCmd.OpenReport const_rptContractReport, acViewPreview, , "[CONTRACT_ID] = " & Forms(const_frmContractBuilderForm)!CONTRACT_ID.value
This seems to work consistently (at least for now!), so not really understanding what was going on there. Even weirder, if I want to print the record I use this:
DoCmd.OpenReport const_rptContractReport, acViewNormal, , "[CONTRACT_ID] = " & Forms(const_frmContractBuilderForm)!CONTRACT_ID.value
This prints the record, but all my unbound fields turn up empty when printed! I think I may be missing something obvious with the printing due to my lack of experience with 2010, as it is just the unbound fields that don't print.
Finally, is there anyway to output a single record to a PDF? I've checked out the OutputTo method, but as far as I can work out this dumps the entire report. It would be so convenient if this could be limited to a single record. Is there any way to do this? I'm thinking that I may have to create a query that will pull out only the single record that I want and use that as the report source. Would this be the best way, or is there a simple command that I'm missing.
Sorry for the long winded post, especially as it's my first technical post on this forum. Any help would be much appreciated.