Hi guys
Brief caveat, I don't understand the full power of Access, I'm sure, and I know even less about reports.
I want to generate a report once a user makes a selection from a combobox and presses a button. I have the report already made, and it is only for printing, so I have the following vba code to display it to the user in print preview.
Code:
'open report page in print preview mode
DoCmd.OpenReport "Calculation Report", acViewPreview
Based on the user choices from prior, my aim is to populate the report (unbound textboxes) using data from a specific record (single date and equipment ID) but from several different tables for different tests performed.. The returned values then need to be subjected to some calculations which use data from "reference" tables etc. and deposited back on the form in another textbox. Doing such a thing on a form is a doddle and using DLookup I can quickly and easily make the functions I need.
The part I am struggling with the most is the most basic part, setting the value of a textbox on the report and retrieving the value back in vba. Using testdata, I don't get any errors when it runs, but I don't get any values appearing on the report either. My current code is below, but I have also tried using an intermediary variable as well to no avail (although the value of the intermediary is fine). teststring is just some criteria to find the right record, and that works fine in other parts of the code.
Code:
[Reports]![Calculation Report]![text_hd_norm_field] = CStr(Nz(DLookup("[Norm Field Size]", "[Results_Hutt_Dig]", testString)))
I don't understand why this isn't working, does anyone have any idea where I am going wrong.