churva_churva -9 Junior Poster
Public con As ADODB.Connection
 Public cmd As ADODB.Command
 Public dept_rs As ADODB.Recordset
 Public gen_rs As ADODB.Recordset
 Public stud_rs As ADODB.Recordset
 Public sql As String

Private Sub cmdExit_Click()
    con.Close
    End
End Sub

Private Sub cmdSave_Click()
    With cmd
        .ActiveConnection = con
        .CommandText = "student_table"
        .CommandType = adCmdTable
    End With
   
    With stud_rs
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Open cmd
    End With
        With dept_rs
            .CursorLocation = adUseClient
            .CursorType = adOpenDynamic
            .LockType = adLockOptimistic
            .Open
        End With
        gen_rs!lidno = gen_rs!lidno + 1
        gen_rs.Update
      Me.lblidno.Caption = "11" & Format(gen_rs!lidno, "000000")
     stud_rs!lname = Trim(Me.txtlname.Text)
     stud_rs!fname = Trim(Me.txtfname.Text)
     stud_rs!Mname = Trim(Me.txtmname.Text)
     stud_rs!ylevel = Trim(Me.txtylevel.Text)
     stud_rs.Close
    
End Sub

 Private Sub Form_Load()
    Set con = New ADODB.Connection
    Set cmd = New ADODB.Command
    Set dept_rs = New ADODB.Recordset
    Set gen_rs = New ADODB.Recordset
    Set stud_rs = New ADODB.Recordset
        With con
            .ConnectionString = "Provider = microsoft.jet.oledb.4.0; data source = C:\Users\Home\Desktop\forms\Database\it220_2011.mdb"
            .Open
        End With
       
            With cmd
                .ActiveConnection = con
                .CommandText = "gen_table"
                .CommandType = adCmdTable
            End With
           
            With gen_rs
                .CursorLocation = adUseClient
                .CursorType = adOpenDynamic
                .LockType = adLockOptimistic
                .Open cmd
            End With
                sql = "select * from dept_table"
                Set dept_rs = con.Execute(sql)
                dept_rs.MoveFirst
                Do Until dept_rs.EOF = True
                    Me.Combo1.AddItem (dept_rs!dcode)
                    dept_rs.MoveNext
                 Loop
                 dept_rs.Close
                 Me.lblidno.Caption = "11" & Format(gen_rs!lidno, "000000")

End Sub

what do you think is the problem with this,if i click save the is error is like this either BOF OR EOF is true,the current record is deleted.requested operation need current record.

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.