The database consists of 9 tables. Each table represents a different aspect of the equipments' configuration. In it's most simple form, equipment would consist of a motor and a directly attached, driven piece of equipment. In other cases they'd be attached by a connecting device that could be a coupling, a belt assembly, or a chain assembly. Still others could have a gear reducer in the middle and then a second connecting assembly. Typically the equipment is associated with an equipment #.
So that's how I built the database. 9 tables each with the primary key being the [Equipment Number], of which anywhere from 2 to 5 tables will contain data for that particular piece of equipment. My Equipment_Form is the main form with a tab control to subforms for each of the other equipment attributes (see picture).
How it works is:
On the Equipment tab, the arrangement is selected with the check boxes. It only allows 1 check box to be selected per zone, and the tabs appear and disappear according to what boxes are checked. After entering all data on each tab, the record can be locked with a check box on the equipment tab. This helps to keep the data from being accidently changed. But it can be unchecked at any time to allow for editing of the record.
All these parts appear to work as needed. But I want to be able to create a report of the current record, but I can't seem to get my head around how to set it up completely.
I have a report [Datasheet] built with all of the possible fields layed out where I want them to print (a template, if you will). I have a [Datasheet_Query] with all of the fields of each of the 9 tables. I have a button control on the Equipment tab of [Equipment_Form]. The [Equipment Number] is on each tab, but I'm thinking about moving it to the Header section of the main page and taking out all the other references to it.
I've tried everything I can think of trying with the coding and have had various degrees of luck.
My code is currently:
BTW: The primary key is set as text because sometimes it may have a
letter at the end of the number.
The report previews as it's layed out. But various attempts at fixing it have given the following results:
Sometimes only the Equipment portion gets data. Usually the data fields are blank. Sometimes it says "#NAME?" in most of the data fields and a few are blank. It just doesn't seem to pass the [Equipment Number] value
to wherever it needs to go.
What should the record source for the report (Datasheet) be? I've tried it as blank, as Datasheet_Query, as Equipment_Form, and I've tried the Query Build wizard.
With the current code, and the Record Source set by the Query Builder, when I press the button:
It asks for input to Forms!Equipment![Equipment Number], then generates the report, as per the layout, but without the data.
So that's how I built the database. 9 tables each with the primary key being the [Equipment Number], of which anywhere from 2 to 5 tables will contain data for that particular piece of equipment. My Equipment_Form is the main form with a tab control to subforms for each of the other equipment attributes (see picture).
How it works is:
On the Equipment tab, the arrangement is selected with the check boxes. It only allows 1 check box to be selected per zone, and the tabs appear and disappear according to what boxes are checked. After entering all data on each tab, the record can be locked with a check box on the equipment tab. This helps to keep the data from being accidently changed. But it can be unchecked at any time to allow for editing of the record.
All these parts appear to work as needed. But I want to be able to create a report of the current record, but I can't seem to get my head around how to set it up completely.
I have a report [Datasheet] built with all of the possible fields layed out where I want them to print (a template, if you will). I have a [Datasheet_Query] with all of the fields of each of the 9 tables. I have a button control on the Equipment tab of [Equipment_Form]. The [Equipment Number] is on each tab, but I'm thinking about moving it to the Header section of the main page and taking out all the other references to it.
I've tried everything I can think of trying with the coding and have had various degrees of luck.
My code is currently:
Code:
DoCmd.OpenReport "Datasheet", acViewPreview, , "Forms!Equipment![Equipment Number]='" & Me![Equipment Number] & "'"
BTW: The primary key is set as text because sometimes it may have a
letter at the end of the number.
The report previews as it's layed out. But various attempts at fixing it have given the following results:
Sometimes only the Equipment portion gets data. Usually the data fields are blank. Sometimes it says "#NAME?" in most of the data fields and a few are blank. It just doesn't seem to pass the [Equipment Number] value
to wherever it needs to go.
What should the record source for the report (Datasheet) be? I've tried it as blank, as Datasheet_Query, as Equipment_Form, and I've tried the Query Build wizard.
With the current code, and the Record Source set by the Query Builder, when I press the button:
It asks for input to Forms!Equipment![Equipment Number], then generates the report, as per the layout, but without the data.