Client_____Country___Period___Prod1___Prod2___Prod 32
Microsoft__Germany___ 2011 ___ 45 ___ 60 ___ 85
Client, Country and Period would give unique record, so I would use something like this code:
Expand|Select|Wrap|Line Numbers
- rs.Open "tblData", cn, adOpenStatic, adLockOptimistic
- sCriteria = "(([ClientID]='" & Form_frmMain.cmbClient & "') AND (" & "[CountryID]='" & Form_frmMain.cmbCountry & "') AND (" & "[Period]='" & Form_frmMain.cmbPeriod & "'))"
- rs.Filter = sCriteria
- Form_frmMain.txtProduct1 = rs![Product1]
- Form_frmMain.txtProduct2 = rs![Product2]
- ...
- ...
- Form_frmMain.txtProduct32 = rs![Product32]
ClientID__CountryID__Period__ProductID__Sales
___1_________2_______2011_______1_______ 45
___1_________2_______2011_______2_______ 60
...
...
___1_________2_______2011_______32______ 60
So now my code from above can't work, because Client, Country and Period will not give unique combination.
I would need to filter it further by the Product to find the unique record.
But since there is let's say 32 products, I would need to use the filter criteria 32 times (for each product once), instead of just once for all products like I was doing before.
I suppose it would have significant influence on execution speed as well?
The second problem is that now I have ProductID which I need to match, but on the form I have text labels that show which product it is and textboxes that represent revenue for each of these products.
So, how do I match the ProductID in the table and Product shown on form?
Expand|Select|Wrap|Line Numbers
- rs.Filter = "(([ClientID]='" & Form_frmMain.cmbClient & "') " & _
- "AND (" & "[CountryID]='" & Form_frmMain.cmbCountry & "') " & _
- "AND (" & "[Period]='" & Form_frmMain.cmbPeriod & "'))" & _
- "AND (" & "[ProductID]='" & Form_frmMain.? & "'))"
I hope I made myself clear to some degree.
So what is the right way to do this?
BTW. I know I could use DLOOKUP to populate it, but I've read somwehere it's not the best way since it has effect on the speed of execution so much.
Thanks!