Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
227 views
in Technique[技术] by (71.8m points)

database - How to use the DBLookupComboBox component?

I set up a basic one-to-many pair of tables in a database (a Borrower can have many books, a Book can have only one borrower). I have a form to add a Book, with edit boxes for other fields and thought I could use a DBLookupComboBox for a Borrower field. It should dropdown Borrower names, and when the user clicks Save, the new Book record should include a Borrower ID (matching the displayed Borrower name).

I set the combo box's

`DataSource` to the `Book DataSource` 
`DataDield` to `BorrowerID` 
`ListSource` is the `Borrower DataSource` 
`ListField` is `BorrowerName` 
`KeyField` is `BorrowerID` 

The combobox displays the expected list of names.

The Save event handler, I assume, should be something like

    tblBook.Insert;
    tblBook['Title'] := edtTitle.Text;
    tblBook['Author'] := edtAuthor.Text;
//    tblBook['BorrowerID'] := What goes here?
    tblBook.Post;

What I find is that a new record is seemingly posted any time I change the DBComboLookupBox value. And I am unsure what's happening when I run the event handler.

question from:https://stackoverflow.com/questions/65835874/how-to-use-the-dblookupcombobox-component

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...