Another ComboBox lookup query!
Hi All you experts, anyone help me with this?
I have a data entry form with a combo box cboIndustry filled by the SQL
SELECT Industries.IndustryID, Industries.IndDescription FROM Industries;
The field IndustriesID contains multiple entries in each row e.g. Mining of coal, extraction of Peat
This makes the look up function complex, so I am needing a lookup table to be triggered by the not in list property.
Private Sub cboIndustry_NotInList(NewData As String, Response As Integer)
DoCmd.OpenForm "frmIndustryLookup",,,,,acDialog, NewData
Response = 0
End Sub
The form IndustryLookup has an unbound combo box cboIndustLook, row source
SELECT Industries.IndustryID, Industries.IndDescription FROM Industries WHERE IndDescription like "**";
frmIndustryLookup has the following code attached:
Private Sub Form_Load()
cboIndustLook.RowSource= "SELECT Industries.IndustryID, Insustries.IndDescription FROM Industries WHERE IndDescription like "*" & OpenArgs & "*"
cboIndustLook.Requery
cboIndustLook.SetFocus
cboIndustLook.Dropdown
End Sub
cboIndustLook has the following code
Private Sub cboIndustLook_Change()
Forms![Patient information].cboIndustry = cboIndustLook.Column(2, cboIndustLook.ListIndex)
DoCmd.Close
End Sub
On entering an industry not on list item the code functions as far as opening the frmIndustryLook and selecting possible matches for the data entered in [Patient information].cboIndustry but at that point it fails to set this combo box to the item you select in the frmIndustryLook
Any Suggestions???
Thanks Barry
|