how to generate alphanumeric autonumber in Aceess backend with VB6 coding

Option Explicit
Dim cnnADO As ADODB.Connection
Dim tbl As ADOX.Table
Dim ctg As ADOX.Catalog

Private Sub Form_Load()
' Instantiate the ActiveX data objects
Set cnnADO = New ADODB.Connection
Set ctg = New ADOX.Catalog
Set tbl = New ADOX.Table
' Open the database and establish the connection

cnnADO.Open "Provider='Microsoft.Jet.OLEDB.4.0';Data Source=practice.mdb"
Set ctg.ActiveConnection = cnnADO
' Add a new column (field) and make it autoincrementing.
With tbl
   .Name = "Employees"
   Set .ParentCatalog = ctg
   .Columns.Append "EmployeeIDs", adInteger
   .Columns("EmployeeIDs").Properties("AutoIncrement") = True
   
End With
' Append the new column
ctg.Tables.Append tbl

End Sub

Private Sub Form_Unload(Cancel As Integer)
cnnADO.Close
Set ctg = Nothing
Set cnnADO = Nothing
Set tbl = Nothing
End Sub

That should add a new autoincrement field to an existing database. But your request seems to be contradictory: alphanumeric autonumber.

Since the autonumber uses the decimal numbering system, you should only want numbers.

You'll need to add references to the ActiveX data objects library and tp the ADO ext for DDL and Security.

Hank

how to generate alphanumeric autonumber in Aceess backend with VB6 coding

check this code in the attachment.

hope this will help you.
know me your feedback.

regards
Shouvik

thnx 4 reply. but i m not getting file properly. i m not getting in proper zip format. so, if possible againg send it. u can directly send that file 2 my id pranavdv@gmail.com

hi i've sent the file to ur gmail id.
plz check it out and know me ur feedback.

hi i've sent the file to ur gmail id.
plz check it out and know me ur feedback.

i got the file properly through gmail id. thnx for the coding

thanks for your feedback.
now go through the code, check it and ofcourse if you get benefited from that code plz don't forget to post your feedback here.

good luck

regards
Shouvik

hi
shouvik

hope you've the file and thanks for your reply.

if you've benefited from what i sent to you or if you got your answer then plz mark this thread as SOLVED

have a nice day.

regards
Shouvik

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.