Max,
Thanks for responding to my questions. I will answer each one of your questions/comments.
First of all when I do an add record while in the violations form, I never enter any data into the unit form/table. I just read the building unit number from the unit form/table.
- you say you filled field's values in Violation table with a procedure: have you also filled the related fields in Unit table? No. I don't have a procedure to load data into the violation table. I just assumed that if I did an add record, it would populate the fields in the violations table. It does populate all fields in the violation table except the 2 lookup fields. As I mentioned above, I only use the unit table to lookup information. I don't add/update any information in the unit table.
- if you click on the magnifying glass of the two lookup objects, can you open the Unit form to select a new record?. Yes. When I click on the magnifying glass, it opens up the unit form and I can select a record containing the building unit number. It then displays that building unit number in the lookup field in the violations form.
In Violation table you should have records like this:
- vio_building_unit => "150480aaaa5555" When I look at the new row in the violations table, the value of the foreign key is in 'vio_unit_id', not 'vio_building_unit'.
In Unit table you should have records like this:
- unit_id => "150480aaaa5555" The value in unit_id in the unit table matches the value in vio_unit_id in the violations table.
- uni_building_unit => "01-101" Yes.
In lookup object > All tab you should have:
- Field Name => "vio_building_unit" I had the vio_unit_id defined as the field name instead of vio_building_unit since vio_unit_id is the matching foreign key.
and in the Lookup tab you should have:
- ID Field => "unit_id" Yes.
- Code Field => "uni_building_unit" Yes
- Description Field => "uni_building_unit" Yes
- No Description => "Yes" No
I changed the field name in the All tab to 'vio_building_unit' and the 'No Description' to yes in the lookup tab. The following things happened:
- after adding a record, the unit field in the violation edit form is now blank instead of showing a unit number
- the new record does not show in the browse form for violations
- when I look at the violations table, the foreign key value is now in the wrong column. It should. be in vio_unit_id instead of vio_building_unit. If you look at the screen shot below, the first 2 rows were records that were just added after I made the changes to the All tab and Lookup tab. The 3rd and 4th rows came from a spreadsheet of data that was loaded into the violations table. The values for vio_unit_id and Vio_rules_id in the 3rd and 4th rows were populated as foreign keys with a procedure after the data was loaded from the spreadsheet. If you look at the far right column, 'vio_date entered', the value came from the violations form when I did the add record.
foreign key value in wrong column.png
The bottom line for me is that I think the 'lookup' fields are working fine except that they don't populate the corresponding fields in the violations table. When I click on 'Add Record', all fields in the violations table are automatically getting updated except the lookup fields.
Do I need a special procedure to update the violations table for the lookup fields?
Here is one more screen shot showing the logic for the violations form. Since the violations form not only has lookup fields but also drop-down lists, I had to use the SQL statement as seen in this form.
SQL for Violations form.png
I appreciate any help I can get.
John