Friends,I have made a programme where master datas are entered and updated in an Access database. In the database there are several Branches with three digit codes.Under each Branch comes several families with a unique number.I want to generate this uniqe number automatically.. To explain further BranchA with code 100,BranchB with code 200 The families coming under BranchA will have number like 1001,1002,1003 and so on.The familis coming under BranchB will have numbers like 2001,2002,2003 and so on I have written some codes It works But the problem is all the families are serially numbered ie When I enter a family under BrancgB afer entering one under BranchA The Number is generated as 2002 instead of 2001 Can any body help meInline Code Example Here
Private Sub CmdSubmit_Click()
Dim FSN As Single
Set FRS = New ADODB.Recordset
FRS.ActiveConnection = conn
FRS.CursorLocation = adUseClient
FRS.CursorType = adOpenDynamic
FRS.LockType = adLockOptimistic
FRS.Source = "SELECT * FROM Family"
FRS.Open
FSN = (FRS.RecordCount)
If FSN = 0 Then
FSN = 1
Else
FSN = (FSN + 1)
End If
FRS.AddNew
FRS("Fno") = BRN & FSN
FRS("Fname") = TxtFname.Text
FRS("Brname") = CmbBranch.Text
FRS.Update
TxtFno = BRN & FSN
FRS.Requery
ClearAll
CmdSubmit.Enabled = False
TxtMode.SetFocus
End Sub
Here the BRN is the Branch code