by Dan Blank
I needed to design a form where I could see information from two different tables. In theory the tables had no need to become a set. Except that by making a set I could accomplish my task. Most sets get structured so that if you select a parent record you see the child records that pertain to the parent. In my case I wanted to see all child records, no matter which parent record was active. Sort of an Orphaned set if you will.
In My Tool Assignment Database Application I want to see a list of tools that are available to assign to employees. The idea being to see the tool list in the left window and send the tool item over to the right widow with the push of a button. Sort of like a Pick List. Then assign an Employee ID Number to the tool.
To do this I needed a way to Link the two tables. So I used a field called Link. It is a character field with just one character space.
Figure 1 Toolloc table. (the first table)
Figure 2. Possess (the second table)
Then in field rules I went to the table that I was going to use as the parent for this set and set the default value to a simple expression. The simple expression is X, and I checked the box that reads, set default value at start of data entry.
Next I made my set. I linked on the Link field using a one to many link with no referential integrity.
Figure 3 ToolAssgn Set
After that my form was ready for designing.
Figure 4. The completed form.
Each browse window represents data from a different table. No matter which record is selected on the left browse, the records in the right browse remains the same.
What happens is the tool administrator goes to the tool cage with an employee, gets the tools needed for a job, and then the tool administrator assigns the tools to an employee. Each tool is barcoded so the tool administrator can use a query based on the tool id, or scroll down the list to find the tool. Then the send button is pressed, and that tool is displayed in the right window. Then the tool administrator scans the employees ID badge (which is also barcoded) and then the tool is assigned to the employee. From there the tool administrator goes to another form based on another set, and prints out a tool acknowledgement form that the employee signs. Then the tools become the responsibility of the employee.
The code for the send button is:
option strict
dim target as p 'pointer to destination
dim sourcetbl as p 'pointer to source table
'open destination file
target = table.open ("possess",FILE_RW_SHARED)
'establish pointer to source table
sourcetbl = table.current()
'begin entering new record
target.enter_begin()
target.Pn = sourcetbl.Pn
target.CTN = sourcetbl.CTID
target.Serial_No_ = sourcetbl.serialno
target.Link = sourcetbl.Link
'save the record
target.enter_end(.t.)
'close destination file
target.close()
sys_send_keys("{F5}")
BUTTON3.activate()
end
Another example where I use an orphaned set can be downloaded at the Code Archive of the Alpha Message Board, titled An Organizer. The To Do List shows through the form as an orphaned set.