Public con As New ADODB.Connection
Public rec As New ADODB.Recordset
Sub main()
On Error GoTo hell
Set con = New ADODB.Connection
Set rec = New ADODB.Recordset
con.Open "Provider = Microsoft.Jet.Oledb.4.0; Data Source=" & App.Path & "\Revise.mdb"
rec.Open "Select * from Revise", con, 2, 3
rec.MoveFirst
Call fill
Form1.Show
hell:
If Err.Number <> 0 Then
MsgBox "Connection problem" & vbCrLf & vbCrLf & Err.Description, vbCritical, "Ahan"
End If
End Sub
Function fill()
With rec
Form1.txtroll.Text = .Fields(0)
Form1.txtname.Text = .Fields(1)
Form1.txtcrs.Text = .Fields(2)
Form1.txtmark.Text = .Fields(3)
End With
End Function
Function blank()
Form1.txtroll.Text = ""
Form1.txtname.Text = ""
Form1.txtcrs.Text = ""
Form1.txtmark.Text = ""
End Function
Function check()
If Form1.txtroll.Text = "" Then
MsgBox "Please enter RollNo", vbCritical
Else
If Form1.txtname.Text = "" Then
MsgBox "Please enter Name", vbCritical
Else
If Form1.txtcrs.Text = "" Then
MsgBox "Please enter Course Title", vbCritical
Else
If Form1.txtmark.Text = "" Then
MsgBox "Please enter Marks", vbCritical
End If
End If
End If
End If
End Function
and the problem is with my next record
plese can u provide me the code for next record with the message "u are already at last record"
or
correct this code
Private Sub cmdnext_Click()
On Error GoTo hell
If rec.State = adStateOpen Then
rec.Close
End If
rec.Open "select * from Revise", con, 2, 3
rec.MoveNext
Call fill
hell:
If Err.Number <> 0 Then
MsgBox "Error in Syntax" & vbCrLf & vbCrLf & Err.Description, vbCritical, "Ahan"
End If
End Sub
this code returns only one next record
i hope u will help me
i also attach my file
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Oh, and your validation could be changed ---- Use a booolean to say whether validation failed. And then its up to you whether you put pop ups in the code to tell the user.
I am thinking along the lines of a user accidentally hitting return too early and then they get lots of error/validation msgs.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...