I have a Combo box which I'm populating with values from a database. This seems to be working great, the combo box displays values for title, firstname and surname. When I select this value, I also want to populate the email that belongs to that contact in a second field called contact_email.
My initial thought was to add the email field into the select a the 4th item and then split the pItemName and put the value into the contact_email field. This would be fairy easy, but I don't like the idea of having the email address being displayed in the drop down list when I go to pick my contact.
Is there a way of hiding this email value, perhaps making the text white when selection is taking place? or is there another more efficient way of get the email field populated with the correct address.
Ive included my code below to show you what Ive done so far already.
Thanks
Code: Select all
global gConnID, gList1
on MouseDown
If gConnID is a integer then
put label of button "cb_supplier_id" into tSupplierID
put "SELECT title, firstname, lastname FROM supplier_contact WHERE supplierID=" & tSupplierID into tTheSQLQuery
put revDataFromQuery(space, return, gConnID, tTheSQLQuery) into tTheComboBoxData
set itemdelimiter to tab
put empty into gList1
repeat for each line tABC in tTheComboBoxData
put item 1 of tABC&cr after gList1
end repeat
If gList1 is not empty then
set the text of button "cb_supplier_contact" to gList1
else
set the text of button "cb_supplier_contact" to "no contacts"
end if
end if
end MouseDown
on MenuPick pItemName
split pItemName by comma
if (gConnID > 0) then
put "SELECT email " &\
"FROM supplier_contact " &\
"WHERE title=" & pItemName[1] & " firstname=" & pItemName[2] & " lastname=" & pItemName[2] into tTheSQLQuery
put revDataFromQuery(tab, cr, gConnID, tTheSQLQuery) into tTheData
if tTheData begins with "revdberr," then
delete item 1 of tTheData
else
set ItemDel to tab
put item 1 of tTheData into field "fld_supplier"
end MenuPick