There are a number of ways to solve this, one problem appears to be that your database is not normalised as you are storing data twice, buts that's a different issue, alternatively store three columns in your combo and hide two but retrieve data from them when neded.
Instead of opening a recordset try using the DLOOKUP function which accepts a field to lookup, tablename and a criteria statement.
If you want to stick with a recordset you could use a full SQL statement originally or use the filter property or modify your find string. The main thing is that as fund_cd is a text string you need quotes around it so, assuming the current value of fund_cd is held in a variable called sFundCd (you can just use the current value of the combo) and you want to store the fund_currency in sFundCurrency:
1) Using DLOOKUP:
sFundCurrency = DLOOKUP("fund_currency", "fund_type", "fund_cd = '" & sFundCd & "'")
2) Using full SQL:
rst.Open "Select * from fund_type where fund_cd = '" & sFundCd & "'"
sFundCurrency = rst.Fields("fund_currrency").value
rst.close
3) Using recordset filter:
rst.Open "Select * from fund_type"
rst.filter = "fund_cd = '" & sFundCd & "'"
sFundCurrency = rst.Fields("fund_currrency").value
rst.close
4) Using find:
rst.Open "Select * from fund_type"
rst.Find "fund_cd = '" & sFundCd & "'", 0, adSearchForward
sFundCurrency = rst.Fields("fund_currrency").value
rst.close
I think you'll agree that if you stick to current design then DLOOKUP seems easiest.
--
Joe
|