954,582 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Hi.. Respected Friends..

Respected Friends..

I need help from your side..
Im using Visual Basic 6.0 with MS Access, I wish to create a automatic serial number for my program, It will show HITE001.. HITE002...HTTE003... same time it will show in form load stage it will automatically show in combo box( last record + 1). Example last record is HITE004, i need HITE005 on form load stage..

Pls my friends help me...

Thanks in avance..
Bala. R

Bala14726
Newbie Poster
1 post since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

To get the next number, use the following -

Dim oConn As ADODB.Connection
Dim oRs As ADODB.Recordset

'Using MS Access database...
    Dim sConn As String
Dim xCount As Integer
    Dim oConn As New ADODB.Connection 'Declare a new connection...
    Dim oRs As New ADODB.Recordset 'Declare a new recordset...
        
    sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\YourDatabaseNameHere.MDB;Persist Security Info=False"
        
    oConn.Open sConn
    
    oRs.Open "SELECT * FROM YourTableNameHere", oConn, adOpenStatic, adLockOptimistic
    
If oRs.BOF = True Or oRs.EOF = True Then
'No records exist...
xCount = 1
Text1.Text = xCount
Else
xCount = oRs.Recordcount + 1

Text1.Text = xCount
    
    oRs.Close
    oConn.Close
End If


This will however not be the ideal way to get a serial number for your application. The ideal way to do this is to start adding registry values by generating random serial numbers. This is quite advanced, so I will not go into it in this thread.

AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: