SemperSalvus
Programmer
This is probably both a form and query issue, but I decided to post it here.
I am running MS Access 2003.
Here is my bottom line, since the explanation below is long, but thorough, in case you need to understand my issue better.
BOTTOM LINE: I need to display table values (Yellow and Green) in a list box as choices, but have either Yellow or Green selected as the value for the list box's table recordsource, based on a select query (which has only one record that matches).
I have a large table with several hundred fields for conducting facility inspections. Each field is a category or issue that could be found good or bad at a given facility. The user has a choice of Green/Yellow/Red and in some cases just Green/Yellow, depending on the category and its urgency to be corrected if found in a bad state. I will use a simple example of Housekeeping here and use the Green/Yellow options.
The inspections are conducted annually and the form I display to the user shows the info from the last inspection, completely filling out all info in all 300+ fields on the form (which are broken down by major category into tab control pages). This way, they can see if the issue was corrected or not and make changes to the data accordingly, which is a new record in the table for the current inspection (i.e. the previous inspection record does not get overwritten of course).
Everything works perfectly, but it takes about 1.5 minutes for the form to load once the user chooses a building they are inspecting. This is too long and is a pain for the inspector. I discovered that the culprit is the tons and tons of DLookups I used in code to fill out the value for each field. Here is one of the evil DLookups:
In an effort to get rid of DLookup, I figured that my answer is going to be the rowsource property for each list box. Currently the rowsource property is a select query done in query builder that displays the 2 options to the
user, Green and Yellow. The table for that is a simple 2 column table with the ID being G for Green and Y for Yellow, bound to the ID and displaying the words Green and Yellow in the list control. It is named YellowGreen (go figure). I also have RedYellowGreen, RedGreen and another which is a special case of choices, to simply pull just what is needed to display in each unique list control, depending on the category. The recordsource for the control is the table of inspection records and the list box values get stored in the table as simply G or Y, for Green and Yellow respectively.
I am using a named query in the query object view of the mdb to select the last inspection performed, if it in fact exists. Most exist, so the result of this query is a single row of the 300+ columns of catergories. The tons of DLookups are pulling their info from this query. The name of that query is HISTORY_LIB_BUILDING_INSPECTIONS_QUERY.
The field in this example is named HOUSEKEEPING_TRASH.
Every attempt to join the YellowGreen table to the Select Query fails.
Here is one that I tried:
I am not sure if a UNION will help me or what. I have googled this and looked at examples in my Access books, all to no avail.
Attached is a crude printscreen of one of the tab pages.
Thanks in advance for your help.
vr
Bob
I am running MS Access 2003.
Here is my bottom line, since the explanation below is long, but thorough, in case you need to understand my issue better.
BOTTOM LINE: I need to display table values (Yellow and Green) in a list box as choices, but have either Yellow or Green selected as the value for the list box's table recordsource, based on a select query (which has only one record that matches).
I have a large table with several hundred fields for conducting facility inspections. Each field is a category or issue that could be found good or bad at a given facility. The user has a choice of Green/Yellow/Red and in some cases just Green/Yellow, depending on the category and its urgency to be corrected if found in a bad state. I will use a simple example of Housekeeping here and use the Green/Yellow options.
The inspections are conducted annually and the form I display to the user shows the info from the last inspection, completely filling out all info in all 300+ fields on the form (which are broken down by major category into tab control pages). This way, they can see if the issue was corrected or not and make changes to the data accordingly, which is a new record in the table for the current inspection (i.e. the previous inspection record does not get overwritten of course).
Everything works perfectly, but it takes about 1.5 minutes for the form to load once the user chooses a building they are inspecting. This is too long and is a pain for the inspector. I discovered that the culprit is the tons and tons of DLookups I used in code to fill out the value for each field. Here is one of the evil DLookups:
Code:
If
DLookup("HISTORY_LIB_BUILDING_INSPECTIONS_QUERY.HOUSEKEEPING_TRASH",
"HISTORY_LIB_BUILDING_INSPECTIONS_QUERY") <> "" Then
Me.ctlHOUSEKEEPING_TRASH.Value =
DLookup("HISTORY_LIB_BUILDING_INSPECTIONS_QUERY.HOUSEKEEPING_TRASH",
"HISTORY_LIB_BUILDING_INSPECTIONS_QUERY")
End If
In an effort to get rid of DLookup, I figured that my answer is going to be the rowsource property for each list box. Currently the rowsource property is a select query done in query builder that displays the 2 options to the
user, Green and Yellow. The table for that is a simple 2 column table with the ID being G for Green and Y for Yellow, bound to the ID and displaying the words Green and Yellow in the list control. It is named YellowGreen (go figure). I also have RedYellowGreen, RedGreen and another which is a special case of choices, to simply pull just what is needed to display in each unique list control, depending on the category. The recordsource for the control is the table of inspection records and the list box values get stored in the table as simply G or Y, for Green and Yellow respectively.
I am using a named query in the query object view of the mdb to select the last inspection performed, if it in fact exists. Most exist, so the result of this query is a single row of the 300+ columns of catergories. The tons of DLookups are pulling their info from this query. The name of that query is HISTORY_LIB_BUILDING_INSPECTIONS_QUERY.
The field in this example is named HOUSEKEEPING_TRASH.
Every attempt to join the YellowGreen table to the Select Query fails.
Here is one that I tried:
Code:
SELECT YellowGreen.[YellowGreen ID], YellowGreen.Description
FROM YellowGreen
WHERE (((YellowGreen.[YellowGreen ID]) In (SELECT HOUSEKEEPING_TRASH FROM
HISTORY_LIB_BUILDING_INSPECTIONS_QUERY WHERE YellowGreen.[YellowGreen ID]=
HISTORY_LIB_BUILDING_INSPECTIONS_QUERY.HOUSEKEEPING_TRASH)));
I am not sure if a UNION will help me or what. I have googled this and looked at examples in my Access books, all to no avail.
Attached is a crude printscreen of one of the tab pages.
Thanks in advance for your help.
vr
Bob