coasterman
Registered User.
- Local time
- Yesterday, 17:52
- Joined
- Oct 1, 2012
- Messages
- 59
I have a very simple continuous form form with two fields which are bound to the two keys in the junction table sitting between the Customer table and the Pcode tables
cboCusName - Rowsource is column(0) PK from customer table and column(1) the customer name
cboPcode - Rowsource is column(0) PK from Postcode table and column(1) the Postcode
Currently the datasource for the form is the tblCusPcode table but I want to change that to a query so I can seach from an unbound textbox which will have criteria
Like "*" & [frmCus!cboCus] & "*" for the customer but I now realise I cannot expose column(1) in the query directly.
I tried this found on another form
"And in the criteria you put this:
=getComboCol("form_name","cbx_name",2)
but I was getting an "error in compiling this Function" after the query builder - this is what I had entered in the 3rd column of the qry as the Expression rather than the Criteria . I also tried it on the control source of an unbound text box in the detail section of the form itself just to see if I could get any result but again an error.
Cname:getComboCol(["Forms]![frmCus]","[cboCus]",1) I presume this is 0 based so my Customer name would be column (1)
I am no doubt doing something a bit dim so if anyone could set me right I'd be grateful
Thanks
cboCusName - Rowsource is column(0) PK from customer table and column(1) the customer name
cboPcode - Rowsource is column(0) PK from Postcode table and column(1) the Postcode
Currently the datasource for the form is the tblCusPcode table but I want to change that to a query so I can seach from an unbound textbox which will have criteria
Like "*" & [frmCus!cboCus] & "*" for the customer but I now realise I cannot expose column(1) in the query directly.
I tried this found on another form
Code:
Public Function getComboCol(strForm, strCombo, intCol)
getComboCol = Forms(strForm)(strCombo).Column(intCol)
End Function
"And in the criteria you put this:
=getComboCol("form_name","cbx_name",2)
but I was getting an "error in compiling this Function" after the query builder - this is what I had entered in the 3rd column of the qry as the Expression rather than the Criteria . I also tried it on the control source of an unbound text box in the detail section of the form itself just to see if I could get any result but again an error.
Cname:getComboCol(["Forms]![frmCus]","[cboCus]",1) I presume this is 0 based so my Customer name would be column (1)
I am no doubt doing something a bit dim so if anyone could set me right I'd be grateful
Thanks