weneva i select add new & select the comboBox it gives me
(the comboBox )00004 value for all records.........
the code above is stuff i was tryin so no duplicate entries are created....din know how exactly to do it,
this is the original function i used:
CODE
Private Function codgen() As String
Dim rec
Dim conn
Dim cmd
On Error Resume Next
cmd = New ADODB.Command
Set rec = New ADODB.Recordset
Set conn = New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & App.Path & "\Db3.mdb"
conn.Open
cmd.ActiveConnection = conn
If rec.State > 0 Then rec.Close
rec.Open "select max(mid(Sup_id,2)) from supplier", conn, adOpenDynamic, adLockOptimistic
If IsNull(rec(0)) Then
codgen = "S00001"
Else
codgen = "S" & Format(Val(rec(0)) + 1, "00000")
End If
txtcode = codgen
End Function
i posted 2 forms wit Db
thanx
code.zip ( 15.52k )
Number of downloads: 28