Hi everyone,
I have following sql to get Max value of column and i want to add 1 for new account number on after update event of cboType to assign the new account number, in order to do that i have following sql, which find the last account number under the Main account (tblAccounts.AccHeaderID) category, but unable to add 1 to latest value to get new account number.
tblAccountsHeader - PK [AccHeaderID] (Integer)
- [HeadingName] (String)
tblAccounts - PK [AccountNo] (Integer)
- FK [tblAccountHeader].[AccHeaderID]
frmCreateAccount - txtNewAccountNo in this text box i need result.
for example
if i have AccHeaderID is 102 and under the heading i have 102001,102002,102003 accounts then new value should be 102004 and same for all other headings whatever is selected 203,304,502 or any it has to look up the latest account number under this headings and add 1 to give the new number.
How i can do it in after update event of cboType combo box?
I have following sql to get Max value of column and i want to add 1 for new account number on after update event of cboType to assign the new account number, in order to do that i have following sql, which find the last account number under the Main account (tblAccounts.AccHeaderID) category, but unable to add 1 to latest value to get new account number.
Code:
SELECT Max(tblAccounts.AccountNo) AS MaxOfAccountNo, tblAccountsHeader.AccHeaderID
FROM tblAccountsHeader INNER JOIN tblAccounts ON tblAccountsHeader.AccHeaderID = tblAccounts.AccHeaderID
GROUP BY tblAccountsHeader.AccHeaderID
tblAccountsHeader - PK [AccHeaderID] (Integer)
- [HeadingName] (String)
tblAccounts - PK [AccountNo] (Integer)
- FK [tblAccountHeader].[AccHeaderID]
frmCreateAccount - txtNewAccountNo in this text box i need result.
for example
if i have AccHeaderID is 102 and under the heading i have 102001,102002,102003 accounts then new value should be 102004 and same for all other headings whatever is selected 203,304,502 or any it has to look up the latest account number under this headings and add 1 to give the new number.
How i can do it in after update event of cboType combo box?