?
2009-10-30 00:26:35 UTC
i know its too much to ask for........but if possible,pls go through my code. the form has only 3 cmd boxes(add record,save and close) and 2 text boxes (first name and last name)
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub cmdAdd_Click()
txtFirstName.Text = ""
txtLastName.Text = ""
cmdSave.Enabled = True
End Sub
Private Sub cmdClose_Click()
End
End Sub
Private Sub cmdFirst_Click()
rs.MoveFirst
If rs.EOF = False Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub
Private Sub cmdLast_Click()
rs.MoveLast
If rs.EOF = False Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub
Private Sub cmdNext_Click()
rs.MoveNext
If rs.EOF = False Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub
Private Sub cmdPrev_Click()
rs.MovePrevious
If rs.EOF = False Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub
Private Sub cmdSave_Click()
If rs.State Then rs.Close
rs.Open "Select * from basic", con, adOpenKeyset, adLockOptimistic
rs.AddNew
rs.Fields(1) = txtFirstName.Text
rs.Fields(2) = txtLastName.Text
rs.Update
cmdSave.Enabled = False
Form_Load
MsgBox "Record Added Successfully"
End Sub
Private Sub Command1_Click()
End Sub
Private Sub Form_Load()
Set con = Nothing
con.Open "DSN=TTT"
Set rs = Nothing
rs.Open "Select * from basic", con, adOpenKeyset, adLockOptimistic
If rs.RecordCount > 0 Then
txtFirstName.Text = rs.Fields(1)
txtLastName.Text = rs.Fields(2)
End If
End Sub