rbroder
Posts: 67
|
| Posted: 06/04/2010, 2:32 PM |
|
I have a dropdown list of customers on an input form to select the data for the field. However, I want to add a new customer on the fly to the source table for the listbox, and use that data for the field value in the form. What method would you suggest?
|
 |
 |
laneoc
Posts: 154
|
| Posted: 06/04/2010, 3:04 PM |
|
Consider using Autocomplete. As the user types, s/he is prompted to select an existing name. But s/he can enter a different name if needed.
Lane
_________________
Lane |
 |
 |
rbroder
Posts: 67
|
| Posted: 06/05/2010, 7:50 AM |
|
I should have been clearer. The input form is from the table orders. The listbox gets its source from the customers table. If the order is for a new customer, I want to be able to add that customer to the customer table (perhaps a popup window), refresh the list and select the customer for the input form.
|
 |
 |
rbroder
Posts: 67
|
| Posted: 06/06/2010, 2:49 PM |
|
I'm sorry, I must be even clearer. The input form is actually a row in an editable grid, displaying only one row at a time. A possible solution would be to have a new customer field and an add customer button whose click event adds a record to the customer table. But now how to refresh the listbox, and automatically select the new entry?
|
 |
 |
jnunez
Posts: 10
|
| Posted: 06/10/2010, 4:15 AM |
|
Check the following example. Maybe it helps http://examples.codecharge.com/ExamplePack/PopUpList/PopUpList.php?
_________________
Javier |
 |
 |
rbroder
Posts: 67
|
| Posted: 06/10/2010, 1:46 PM |
|
That example has no bearing on this problem. Using that example, try to add a new employee. That is more like my problem. I want to add a record to a table which does not have a form on the current window.
|
 |
 |
Waspman
Posts: 948
|
| Posted: 06/13/2010, 3:48 AM |
|
I do this with custom SQL at before insert event. You can't use last inserted record id as many of the examples on here show cos you may not be the only user inserting a record. So you will have to generate a unique customer id. This has to be something you do with all your customers so it will impact on your scheme.
So use a condition that says if the value in the dropdown list is empty run this script. Take the content from the text box and your generated customer id (and possibly the date and the users who created it) update the appropriate field in your order form and insert them in your customer table.
Like this:
if ($Container->CustomerID->GetValue()==""){ //check list is empty
if ($Container->NewName->GetValue()<>""){ //make sure new name isn't empty
$Container->CustomerID->SetValue($Container->NewCustomerID->GetValue()); //assign new generated customer id to relevant order field
// update customer table
$db = new clsDBConnection1;
$SQL = "INSERT INTO customers (CustomerName, CustomerID) VALUES(".$db->ToSQL($Container->NewName->GetValue(),ccsText).",".$db->ToSQL($Container->NewCustomerID->GetValue(),ccsText).") ";
$db->query($SQL);
$db->close;
}
}
T
_________________
http://www.waspmedia.co.uk |
 |
 |
rbroder
Posts: 67
|
| Posted: 06/13/2010, 7:54 AM |
|
Thanks, that is what I was looking for. Too bad CC doesn't have a combo box like MS Access.
|
 |
 |