i cant add info to my ms access 2003 :( im using vb6.0 with listview ..please help .. i dont know the error .. when im trying to add a codes to add a info to my access .. the error occurs ..
Code:
Private Sub cmdAdd_Click()
On Error GoTo errtrap
If Me.txtName.Text = "" Or Me.txtAdd.Text = "" Or Me.Text1.Text = "" Or Me.Text2.Text = "" Or Me.Text3.Text = "" Or Me.Text4.Text = "" Or Me.Text5.Text = "" Or Me.Text6.Text = "" Or Me.Text7.Text = "" Or Me.Text8.Text = "" Or Me.txteduc(0).Text = "" Then
MsgBox "All fields are required!", vbExclamation, "Error"
Exit Sub
End If
Call dbConnect
Conn.Execute "Insert into tbl_info(info_name,info_address,membership,birthdate,age,sex,status,religion,dialect,studying,education) values('" & Me.txtName.Text & "','" & Me.txtAdd.Text & "','" & Me.Text1.Text & "','" & Me.Text2.Text & "','" & Me.Text3.Text & "','" & Me.Text4.Text & "','" & Me.Text5.Text & "','" & Me.Text6.Text & "','" & Me.Text7.Text & "','" & Me.Text8.Text & "','" & Me.txteduc(0).Text & "' )"
Conn.Close
Set Conn = Nothing
Unload Me
Call loadNew
Exit Sub
errtrap:
Select Case Err.Number
Case -2147467259
MsgBox "The name already exists in the database", vbCritical, "Error"
Case Else
MsgBox Err.Description, vbCritical, "The system encountered an error"
End Select
End Sub
Public Sub loadNew()
frmLoading.Show
frmLoading.lblSub.Caption = "Saving your entry...."
With viewlist.ListView.ListItems
Call dbConnect
SQL = "SELECT tbl_info.* FROM tbl_info order by id_info asc;"
RS.Open SQL, Conn, adOpenDynamic
If Not RS.EOF Then
RS.MoveLast
Set Item = .Add(, , RS!id_info)
Item.SubItems(1) = RS!info_name
Item.SubItems(2) = RS!info_address
Item.SubItems(3) = RS!membership
Item.SubItems(4) = RS!birthdate
Item.SubItems(5) = RS!age
Item.SubItems(6) = RS!sex
Item.SubItems(7) = RS!Status
Item.SubItems(8) = RS!religion
Item.SubItems(9) = RS!dialect
Item.SubItems(10) = RS!studying
Item.SubItems(11) = RS!education
Item.EnsureVisible
End If
RS.Close
Conn.Close
Set Conn = Nothing
End With
Unload frmLoading
MsgBox "New entry was added successfully", vbInformation, "Save"
End Sub
Private Sub Label10_Click()
loans.Show
frmNew.Hide
End Sub
Private Sub Label11_Click()
viewlist.Show
frmNew.Hide
End Sub
Private Sub Label4_Click(Index As Integer)
home.Show
frmNew.Hide
End Sub
Private Sub Label9_Click()
Form1.Show
frmNew.Hide
End Sub
Comment