0

hi,

i had one field in the table(field name: crseid).

for example,i am having 500 courses.i want to start the crseid from :6000(4 digit number)

output:
6001
6002
6003
.
.
.
.
6500

this value must be inserted into my table.


thanks in advance

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by abu taher
0

If you do it by vb with a textbox

Function GetId(TableName As String, FieldName As String, Optional Criteria As String)
    Dim rs As New ADODB.Recordset
        If Criteria = "" Then
        rs.Open "Select max(" & FieldName & ") from " & TableName, conn, adOpenDynamic, adLockReadOnly
        GetId = IIf(IsNull(rs.Fields(0)), 0, rs.Fields(0))
        Else
            rs.Open "Select max(" & FieldName & ") from " & TableName & " where " & Criteria, conn, adOpenDynamic, adLockReadOnly
            GetId = IIf(IsNull(rs.Fields(0)), 0, rs.Fields(0))
        End If
End Function
Private Sub Txtcourse_LostFocus()
txtcrseid.Text = Val(GetId("table1", "[crseid]", " course_name ='" & Txtcourse.Text & "'")) + 1
End Sub

here course name mean if you have several course name. when you type the course name in txtcourse(textbox) it will increase crseid automatically.

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.