Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Lists

Status
Not open for further replies.

teamakesmefart

Technical User
Dec 3, 2003
10
0
0
GB
Help!

I’m reasonably new to Paradox ... not getting on too badly but this one’s got me stumped. I’m using Paradox 9.

I have a form containing a TableFrame and a check box. I want to populate the TableFrame differently depending on whether the check box is ticked or unticked.

If its unticked, I want it to contain the answer to the query

SELECT InsuredID, Name, PostTown
FROM Insured
WHERE InsTypeID = 2 OR InsType = 3

If the check box is ticked, I want it to contain the answer to the query:

SELECT i.InsuredID, i.Name, i.PostTown, rt.Description
FROM Insured i, ContactRelationships cr, ContactRoles rt
WHERE (i.InsTypeID = 2 OR i.InsTypeID = 3)
AND cr.InsuredID = i.InsuredID AND cr.contactID =<#fldContactID.value>
AND rt.RoleID = cr.RoleID

So, as well as the different data return - the second query contains an extra column.

Can anyone tell me how to populate a TableFrame with the result of a query - and how I can alter the column list at runtime?

If this isn’t possible, details of how I acheieve the same thing using different controls would be just as good - though I need the user to be able to select one of the returned items in whichever control I use.


Many thanks in advance
Pete Wright
 
Binding fields in a tableframe 'on the fly' can be achieved easily enough, but to get the table frame looking right, it may be necessary to adjust field and table properties (column with, text alignment and format, etc) since these often reset on a bind. Overall, possibly a lot of code and fiddling about to get the right result.

Consider putting 2 tableframes on the form, on top of each other. The tableframes can be permanently bound to 2 dummy answer tables (in users :pRIV:) with the correct answer table structure. Use the tick box to select the query to run, route the result to the relevant dummy table, and adjust the visible property of the tableframes so that the correct one shows. Tidy up by emptying the dummy answer tables in the init method of the form and stick a 'self.visible = false' in the open method of the tableframes.
 
I would probably do it this way.

1. Create a holding table that has the fields: InsuredID, Name, PostTown, Description, and a logical field called PickMe. Make sure the field sizes will support the largest entry from either result set.

2. Add a tableframe or MRO to the form based on the holding table. Make the PickMe logical field a checkbox in it.

3. When either query is run, have code to empty the holding table, then do an add from Answer.DB to the holding table. In the first set, the Description field will be just have to be empty (or a quick changeto query could insert 'n/a' or something).

4. Use code or another query to discover which record the user checked.

There are probably other ways to accomplish this and you may want to look at basing the tableframe or MRO on a query rather than a table. That way you may be able to do something more dynamic - but you might lose some design control.

Mac :)

&quot;There are only 10 kinds of people in this world... those who understand binary and those who don't&quot;

langley_mckelvy@cd4.co.harris.tx.us
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top