Search
When i click on ADD it changes to SAVE and disables other buttons DELETE UPDATE SEARCH.When i click on SAVE and if texboxes are empty it brings an error,when i click search and i want to cancel the search from the inputbox it brings another error i also want to add cancel button or refresh button.How can i make this project to run well. WHere did i go wrong
Here are my codes
Private Sub Form_Load() Dim str As String Me.Caption = "" Set adoconn = Nothing adoconn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=person.mdb;Persist Security Info=False" str = "select * from pers" rs.Open str, adoconn, adOpenDynamic, adLockPessimistic rs.MoveFirst txtNo.Text = rs(0) txtName.Text = rs(1) txtDistrict.Text = rs(2) txtDob.Text = rs(4) txtPhone.Text = rs(3) txtID.Text = rs(5) End Sub Private Sub cmdSave_Click() rs(0) = txtNo.Text rs(1) = txtName.Text rs(2) = txtDistrict.Text rs(4) = txtDob.Text rs(3) = txtPhone.Text rs(5) = txtID.Text rs.Update MsgBox "The record has been saved successfully.", , "ADD" cmdFirst.Enabled = True cmdLast.Enabled = True cmdNext.Enabled = True cmdPrevious.Enabled = True cmdDelete.Enabled = True cmdSearch.Enabled = True cmdUpdate.Enabled = True cmdSave.Visible = False cmdAdd.Visible = True End Sub Private Sub cmdSearch_Click() Dim key As Integer, str As String key = InputBox("Enter the Persons No whose details you want to know: ") Set rs = Nothing str = "select * from pers where no=" & key rs.Open str, adoconn, adOpenForwardOnly, adLockReadOnly txtNo.Text = rs(0) txtName.Text = rs(1) txtDistrict.Text = rs(2) txtDob.Text = rs(4) txtPhone.Text = rs(3) txtID.Text = rs(5) Set rs = Nothing str = "select * from pers where no=" rs.Open str, adoconn, adOpenDynamic, adLockPessimistic If txtNo Is Null Then MsgBox "Invalid entry .", vbCancel, "Note it..." End Sub
Hello Sir
pano po ba ebackup ang sql server 2005 thru vb6
hope your answer!!!
more power
mrhumble



The problem is very obvious. You did not add error trapping or form validation.
In the cmdSave_Click procedure you could add a code below to validate a form:
etc...
You may try adding error handling also:
On Error GoTo err_Handling
err_Handling:
Msgbox err.description