cobom
Posts: 55
|
| Posted: 11/02/2004, 7:21 AM |
|
I have a empoyee table - when a user logs in the userID variable populates a department field by using ccdlookup. My problem is that I now have secretaries that enter data for several different departments. Aside from adding a drop down or editable field is there a way to populate the department field based on the employee name entered. The employee name field is currently chosen from a listbox and the department field is hidden.
My idea was to use form.field.value=ccdlookup("department_number", "employee_table", ????, dbconnection)
I can not seem to find a where_clause that will use the name selected with an "on change" action.
_________________
cmckinney@searay.com
Will program for a Sea Ray 680 SS ;} |
 |
 |
mrachow
Posts: 509
|
| Posted: 11/02/2004, 2:30 PM |
|
Is the listbox placed on a search form?
In that case it will be populated by submit/search. Than it can be accessed by CCGetParam("nameOfListbox", Empty)
Regards,
Michael
_________________
Best regards,
Michael |
 |
 |
cobom
Posts: 55
|
| Posted: 11/02/2004, 3:38 PM |
|
The employee listbox and dept_number hidden field are both on a record. I need the dept_number field populated based on the employee selected - not based on who is logged on. The employee table has both fields - the submit puts that data plus additional data in another table. For large departments the user entering data has the employee name and all the other data in front of them - but would have to look elsewhere for the department number. Our CAD users and other computers users enter their own info - so I can easily populate the department_number with ccdlookup based on userID session for them. These users are redirected to a different page for access to their record form - the name and department are both autopopulated - the department field is hidden (they do not need to see this).
_________________
cmckinney@searay.com
Will program for a Sea Ray 680 SS ;} |
 |
 |
dataobjx
Posts: 181
|
| Posted: 11/03/2004, 4:43 AM |
|
In the BeforeBuildUpdate and or BeforeBuildInsert event, you will need to derive the value from the listbox.
Dim empID
empID = record1.lboxEmployee.value
sResult = CCDLookup("departmentid", "emp_table", "emp_id=" & CCToSQL(empID, "Integer"), DBIntranet)
'repopulate the department_number hidden field.
record1.department_number.value = sResult
This should work more smoothly than attempting to derive the value during the onChange event.
_________________
www.DataObjx.net
www.mydigitalapps.com |
 |
 |
cobom
Posts: 55
|
| Posted: 11/03/2004, 1:10 PM |
|
When I add this to the BeforeBuildInsert event, save and publish the page, I can no longer submit the form. No error - just there is something wrong with this page and a HTTP 500 - Internal server error
Function Employee_Direct_Labor_DataSource_BeforeBuildInsert() 'Employee_Direct_Labor_DataSource_BeforeBuildInsert @17-C037A790
'Custom Code @100-73254650
' -------------------------
Dim empID
empID=Employee_Direct_Labor.Employee_Name.value
sResult=CCDLookup("Dept_Number", "Employee_Table", "Employee_Name=" & CCToSQL(empID, "Integer"),DBLabortrack)
Employee_Direct_Labor.Dept_Number.value=sResult
' -------------------------
'End Custom Code
End Function 'Close Employee_Direct_Labor_DataSource_BeforeBuildInsert @17-54C34B28
_________________
cmckinney@searay.com
Will program for a Sea Ray 680 SS ;} |
 |
 |
peterr
Posts: 5971
|
| Posted: 11/03/2004, 2:35 PM |
|
I recommend that you first resolve your HTTP 500 error: http://www.webwizguide.info/asp/faq/friendly_HTTP_error_messages.asp
Once this is taken care of you should see the exact error message that should provide more details about the problem.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
cobom
Posts: 55
|
| Posted: 11/03/2004, 3:57 PM |
|
I did Peter, sResult was not a defined variable, even though I tried to declare DIM sResult. At first I thought sResult was part of ASP or something. Anyway - changing to:
DIM empID
empID=Employee_Direct_Labor.Employee_Name.value
Employee_Direct_Labor.Dept_Number.value=CCDLookup("Dept_Number", "Employee_Table", "Employee_Name=" & CCToSQL(empID, "Integer"),DBLabortrack)
And moving it to BeforeInsert appears to have fixed it.
Thanks all..
_________________
cmckinney@searay.com
Will program for a Sea Ray 680 SS ;} |
 |
 |
|