Dear all,
I am quite new to Access and VBA.
I am working on a small database for my company, where the main purpose would be automatic contract number generation.
We are managing 4 accounts at the moment (expecting to increase) and we need to keep separate contract 'counters' for each account.
I have two tables, one which contains all transactions (tblTransactions), and one which contains account information (tblAccounts), a query (qryAccTran), which combines the two tables with a Lookup field AccountRef and has some calculated fields.
What I am trying to achieve is to make a contract number generator on btnGenerate_click() on my form frmNewTransaction.
The number must increment in sequence, but with reference to the account used.
eg. ACA00001, then ACA00002, ACA00003 and if I choose a different account it would start again from ACB00001 then ACB00002 and etc.
It would have been easy if I needed one general 'counter' which would be in a separate field and I would just combine the AccountRef and next available number using Dmax. However because my contracts are Alphanumeric the Dmax does not seem to work and gives Value mismatch error.
Can you please advice me on what function or code should I use to overcome this problem, as I have spent hours looking online and trialing different methods but none were successful.
I will be very grateful for your help.
I am quite new to Access and VBA.
I am working on a small database for my company, where the main purpose would be automatic contract number generation.
We are managing 4 accounts at the moment (expecting to increase) and we need to keep separate contract 'counters' for each account.
I have two tables, one which contains all transactions (tblTransactions), and one which contains account information (tblAccounts), a query (qryAccTran), which combines the two tables with a Lookup field AccountRef and has some calculated fields.
What I am trying to achieve is to make a contract number generator on btnGenerate_click() on my form frmNewTransaction.
The number must increment in sequence, but with reference to the account used.
eg. ACA00001, then ACA00002, ACA00003 and if I choose a different account it would start again from ACB00001 then ACB00002 and etc.
It would have been easy if I needed one general 'counter' which would be in a separate field and I would just combine the AccountRef and next available number using Dmax. However because my contracts are Alphanumeric the Dmax does not seem to work and gives Value mismatch error.
Can you please advice me on what function or code should I use to overcome this problem, as I have spent hours looking online and trialing different methods but none were successful.
I will be very grateful for your help.