Dave
|
| Posted: 03/16/2005, 6:45 PM |
|
I have 2 tables, "clients" and "projects". I am creating a page that shows the client names in a drop down, but submits the client ID into the project table. I have no problem pulling the client names from the client table into the form, but I am having trouble pulling the corresponding ID to save in the projects table. I am new to both PHP and CodeCharge, so any help would be appreciated. Thanks.
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 03/17/2005, 12:14 AM |
|
The ID should be saved automatically if you specify it in the "Bound Column" property of your listbox. If this doesn't work for you, could you please describe what happens.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Dave
|
| Posted: 03/17/2005, 3:42 AM |
|
Here are my tables:
clients (client_id, client_name)
projects (proj_id, proj_name, client_id).
The form contains a drop down (which includes the client_name) and a text box to enter the proj_name. The control source for the drop down is clients.client_name. The text column for the dropdown is clients.client_name. I set the bound column to projects.client_id. The data source for the drop down is:
SELECT * FROM projects RIGHT JOIN clients ON
projects.CLIENT_ID = clients.CLIENT_ID
I get the following error on my form:
The value in field CLIENT ID is required.
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 03/17/2005, 12:20 PM |
|
Something's wrong. It should not be possible for you to select projects.client_id as bound column since this refers to a different table than where your clients are. And you don't need to use an SQL with 2 tables in the data source for the drop down. All you need in your drop-down is the list of clients, so the data source should be "clients" , text column "client_name" and bound column "client_id".
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Dave
|
| Posted: 03/17/2005, 1:34 PM |
|
I'm not sure I understand what a bound column is.
I understand that I only need the client table in the data source for the drop down. However, I don't want to update the client table. I want to update the project table.
|
|
|
 |
Dave
|
| Posted: 03/17/2005, 2:13 PM |
|
If I remove the SQL from the control source and only use the clients table, I get the error below. I do not have a client_name field in my projects table. I guess I could manually modify the SQL query, but is this the best approach? I want to set this up correctly in CodeCharge.
Database error: Invalid SQL: UPDATE projects SET CLIENT_NAME='1', PROJ_NAME='TEST'
MySQL Error: 1054 (Unknown column 'CLIENT_NAME' in 'field list')
Session halted.
|
|
|
 |
Dave
|
| Posted: 03/17/2005, 2:14 PM |
|
Thanks for you help. I solved the problem.
|
|
|
 |
Dave
|
| Posted: 03/17/2005, 2:38 PM |
|
Quote Dave:
I got the form to submit, but I lost the Add button and only have the Submit and Delete buttons. These don't make sence. Any idea why this may have happened?
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 03/17/2005, 2:53 PM |
|
Possibly you changed the data source of your form which you shouldn't have (just a guess).
So please make sure that your form's datasource is "projects".
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |