0

hello guys need some help, i need to generate id the problem is i cannot get the last row from database

logical view

DATABASE
tbloutlet
PCSO20121
PCSO20122
PCSO20123

NOW
need to get
"PCSO20123"
select the last character '3' using mid
after selecting '3' convert to int and add to 1 VAl=3+1
"PCSO2012" & VAL

Main problem cannot select last row from the database "PCSO20123"

rs.Open "select max(OUTLET_ID) as IDS from tblOutlet", conn, adOpenStatic, adLockReadOnly
'ids = rs.Fields("IDS")
If rs.BOF And rs.EOF Then
    nonIds = "PCSO" & strYear & "1"
    txtOutletID.Text = ids
    Else
        genid = Mid$(rs.Fields("IDS"), 8, 1)
        inty = CInt(genid) + 1
        idhand = "PCSO" & strYear & CStr(inty)
    End If
    txtOutletID.Text = genid
   
End Sub
3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by debasisdas
0

Since you are always concatenating the generated number to a fixed string, you need to generate only the number part from DB. Using the logic of Max(field)+1 should work fine for you.

Edited by debasisdas: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.