In my application, I'm faced with many situations where I have to store
many-to-many data in link tables. In order for this to make sense to the
user, I'm going to have to "translate" the FKs in these link tables to
something meaningful both when displaying data and saving entries back to
the database. You know:
Table books
id I, ;
title C(100)
Table authors
id I, ;
author C(100)
Table bookauthors
id I, ;
bookid I, ;
authorid I
In VFP I can do (code off the top of my head, leaving out all the OO stuff):
FUNCTION GetBookAuthor(nPK)
SELECT books.title, authors.author FROM books ;
JOIN bookauthors ON bookauthors.id = nPK ;
JOIN authors ON authors.id = bookauthors.authorid ;
WHERE books.id = bookauthors.bookid ;
INTO CURSOR myData
SELECT myData
MyForm.MyTextbox1.Value = myData.title
MyForm.MyTextbox2.Value = myData.author
A common scenario, for sure--but one for which I can't find Dabo demo code.
I've been trying to wade through the classes and code for a while now to
figure this out but I just can't find it. I don't want to use any of the
stock forms. I want, for now, to create a simple form so I can understand
how to call a custom query of my database for a particular purpose.
I have a form with a spinner, a button, and a textbox. When I choose a
number in the spinner, representing a PK value, I want to be able to press
the button and have a value from a record with that PK show up in the textbox.
It seems to me that in order to do this, I need a biz object that manages
the table, with a method like:
getValForPK(self,pk=0)
self.AddWhere("id = " + str(pk))
self.Requery()
# somehow here I access the returned dataset and pluck out the field
value
# using a split function I imagine....
return myValue
Then my button's onHit can do (yes, I know it should call a form method
that does the following):
self.Form.MyTextbox.Value =
self.Form.MyBizObj.getValForPK(pk=self.Form.mySpinner.value)
That's as far as I'm able to get. Can someone fill in the blanks?
Thanks very much.
Ken Dibble
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.3/699 - Release Date: 2/23/2007 1:26
PM
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users