Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: DBComboxBox issue


This question is answered.


Permlink Replies: 3 - Last Post: Oct 13, 2014 6:49 AM Last Post By: Michael Hackney
Michael Hackney

Posts: 28
Registered: 9/4/14
DBComboxBox issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 10, 2014 8:55 AM
I'm creating an order entry application, whereas when a customer wants to schedule service a new work order is generated. So I have a Work Orders table (WorkOrdersIn.db) which contains a CustID field, but not a company name field, as the company name is stored in the Customers table (Customer.db). So when creating a new work order the user selects a company name from a DBComboBox, which is being populated by a datasource query that grabs all the company names from the customer table. Once the user selects the company name from the drop-down list, I have a procedure that executes which locates that company name in the Customer table and grabs the associated CustID from that record. That part works, but the problem is that when this procedure executes the Locate (line of code), it actually populates the first record of the Customer table with the company name the user selected from the DBComboBox dropdown list... which is a problem. So when this command ( if not POE_Data.Customer.Locate('CompanyName',SCustName, []) then) executes, it is overwriting the Company name in the first record of the customer table. It appears that the locate is not making the located record the current record as it supposed to.

Why is this behaving like this, and is there a better/different way to accomplish this? Would a DBLookupComboBox work better in this situation?
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: DBComboxBox issue
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 11, 2014 12:59 AM   in response to: Michael Hackney in response to: Michael Hackney
Michael Hackney wrote:

I'm creating an order entry application, whereas when a customer
wants to schedule service a new work order is generated. So I have a
Work Orders table (WorkOrdersIn.db) which contains a CustID field,
but not a company name field, as the company name is stored in the
Customers table (Customer.db). So when creating a new work order the
user selects a company name from a DBComboBox, which is being
populated by a datasource query that grabs all the company names from
the customer table. Once the user selec ts the company name from the
drop-down list, I have a procedure that executes which locates that
company name in the Customer table and grabs the associated CustID
from that record.

You are using the wrong control class. Use a TDBLookupCombobox, it
allows the user to pick a record from a table A and will automatically
assign the value of a particular field in table A to a field in table B
(in this scenario B ist the master and A is the detail table).


--
Peter Below (TeamB)

Michael Hackney

Posts: 28
Registered: 9/4/14
Re: DBComboxBox issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 13, 2014 6:33 AM   in response to: Peter Below in response to: Peter Below
Okay, I've added a DBLookupComboBox, but it appears to be disabled. Everything appears enabled and active. Here's the setup:

datasource - linked to the table which I am editing... 'WorkOrdersIn'
datafield - the name of the field in the table which I am editing... 'CustID'
listsource - linked to the query which populated the DBLookuoComboBox... 'CustNames'
list field - the name of the field from 'CustNames' which I want to display... 'CompanyName'
key field - the name of the field from 'CustNames' which will be inserted into the 'WorkOrdersIn' record... 'CustID'

What am I missing?

Peter Below wrote:
Michael Hackney wrote:

I'm creating an order entry application, whereas when a customer
wants to schedule service a new work order is generated. So I have a
Work Orders table (WorkOrdersIn.db) which contains a CustID field,
but not a company name field, as the company name is stored in the
Customers table (Customer.db). So when creating a new work order the
user selects a company name from a DBComboBox, which is being
populated by a datasource query that grabs all the company names from
the customer table. Once the user selec ts the company name from the
drop-down list, I have a procedure that executes which locates that
company name in the Customer table and grabs the associated CustID
from that record.

You are using the wrong control class. Use a TDBLookupCombobox, it
allows the user to pick a record from a table A and will automatically
assign the value of a particular field in table A to a field in table B
(in this scenario B ist the master and A is the detail table).


--
Peter Below (TeamB)

Michael Hackney

Posts: 28
Registered: 9/4/14
Re: DBComboxBox issue  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 13, 2014 6:49 AM   in response to: Michael Hackney in response to: Michael Hackney
Update: Sorry, I found a line that was closing one of the related datasources.

Michael Hackney wrote:
Okay, I've added a DBLookupComboBox, but it appears to be disabled. Everything appears enabled and active. Here's the setup:

datasource - linked to the table which I am editing... 'WorkOrdersIn'
datafield - the name of the field in the table which I am editing... 'CustID'
listsource - linked to the query which populated the DBLookuoComboBox... 'CustNames'
list field - the name of the field from 'CustNames' which I want to display... 'CompanyName'
key field - the name of the field from 'CustNames' which will be inserted into the 'WorkOrdersIn' record... 'CustID'

What am I missing?

Peter Below wrote:
Michael Hackney wrote:

I'm creating an order entry application, whereas when a customer
wants to schedule service a new work order is generated. So I have a
Work Orders table (WorkOrdersIn.db) which contains a CustID field,
but not a company name field, as the company name is stored in the
Customers table (Customer.db). So when creating a new work order the
user selects a company name from a DBComboBox, which is being
populated by a datasource query that grabs all the company names from
the customer table. Once the user selec ts the company name from the
drop-down list, I have a procedure that executes which locates that
company name in the Customer table and grabs the associated CustID
from that record.

You are using the wrong control class. Use a TDBLookupCombobox, it
allows the user to pick a record from a table A and will automatically
assign the value of a particular field in table A to a field in table B
(in this scenario B ist the master and A is the detail table).


--
Peter Below (TeamB)

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02