Thread: Need help
View Single Post
  #1 (permalink)  
Old 05-08-2008, 12:49 AM
yonghan yonghan is offline
Newbie
 
Join Date: May 2008
Posts: 19
Credits: 0
Rep Power: 2
yonghan is on a distinguished road
Default Need help

Guys..i need help please..I got problem when i delete data,the program close after it..Here are the code..Please help me..Thanks a lot..
Code:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    Dim intJawab As Byte
    Dim strGolonganID, strSupplierID As String
    Dim j As Integer
    
    j = rsPerusahaan.RecordCount
    Select Case Button.Key
        Case "New"
            
            If j <> 0 Then
            MsgBox "You can't add a new data", , "Warning"
            Else
            If Not StatusBar1.Panels(1).Text = "Ready" Then
                Exit Sub
            Else
                StatusBar1.Panels(1).Text = "New"
                EnableColor
                EnableForm
                ClearForm
                DisableLock
                
                
            End If
           End If
        Case "Save"
            If Not StatusBar1.Panels(1).Text = "New" And Not StatusBar1.Panels(1).Text = "Edit" Then
                Exit Sub
            Else
            
                If StatusBar1.Panels(1).Text = "New" Then
                    If Validate Then
                        intJawab = MsgBox("Save new data?", vbYesNoCancel + vbExclamation, "Save data")
                        If intJawab = 6 Then    'vbYes
                            rsPerusahaan.AddNew
                            rsPerusahaan!nama = IIf(Not IsNull(txtNama.Text), txtNama.Text, "")
                            rsPerusahaan!alamat1 = IIf(Not IsNull(txtAlamat1.Text), txtAlamat1.Text, "")
                            rsPerusahaan!alamat2 = IIf(Not IsNull(txtAlamat2.Text), txtAlamat2.Text, "")
                            rsPerusahaan!Kota = IIf(Not IsNull(txtKota.Text), txtKota.Text, "")
                            rsPerusahaan!Zip = IIf(Not IsNull(txtZip.Text), txtZip.Text, "")
                            rsPerusahaan!telepon = IIf(Not IsNull(txtPhone.Text), txtPhone.Text, "")
                            rsPerusahaan!fax = IIf(Not IsNull(txtFax.Text), txtFax.Text, "")
                            rsPerusahaan!kontak = IIf(Not IsNull(txtKontak.Text), txtKontak.Text, "")
                            rsPerusahaan!NPWP = IIf(Not IsNull(txtNPWP.Text), txtNPWP.Text, "")
                            rsPerusahaan!Ket1 = IIf(Not IsNull(txtKet1.Text), txtKet1.Text, "")
                            rsPerusahaan!Ket2 = IIf(Not IsNull(txtKet2.Text), txtKet2.Text, "")
                            rsPerusahaan!Ket3 = IIf(Not IsNull(txtKet3.Text), txtKet3.Text, "")
                            rsPerusahaan.Update
                            MsgBox "Successfully saved."
                        Else
                            If intJawab = 7 Then    'vbNo
                                MsgBox "No"
                            Else
                                MsgBox "Cancel"     'vbCancel
                            End If
                        End If
                    End If
                Else
                    If StatusBar1.Panels(1).Text = "Edit" Then
                       
                       
                        intJawab = MsgBox("Would you save the edited data?", vbYesNoCancel + vbExclamation, "Save data")
                        If intJawab = 6 Then    'vbYes
                            rsPerusahaan.Edit
                            rsPerusahaan!nama = txtNama.Text
                            rsPerusahaan!alamat1 = txtAlamat1.Text
                            rsPerusahaan!alamat2 = txtAlamat2.Text
                            rsPerusahaan!Kota = txtKota.Text
                            rsPerusahaan!Zip = txtZip.Text
                            rsPerusahaan!telepon = txtPhone.Text
                            rsPerusahaan!fax = txtFax.Text
                            rsPerusahaan!kontak = txtKontak.Text
                            rsPerusahaan!NPWP = txtNPWP.Text
                            rsPerusahaan!Ket1 = txtKet1.Text
                            rsPerusahaan!Ket2 = txtKet2.Text
                            rsPerusahaan!Ket3 = txtKet3.Text
                            rsPerusahaan.Update
                            MsgBox "Successfully saved."
                        Else
                            If intJawab = 7 Then    'vbNo
                                MsgBox "No"
                            Else
                                MsgBox "Cancel"     'vbCancel
                            End If
                        End If
                    End If
                End If
            End If
            'DisableForm
            DisableColor
            StatusBar1.Panels(1).Text = "Ready"
        Case "Undo"
            If StatusBar1.Panels(1).Text = "New" Or StatusBar1.Panels(1).Text = "Save" Or StatusBar1.Panels(1).Text = "Edit" Or StatusBar1.Panels(1).Text = "Delete" Then
                ClearForm
                EnableLock
                DisableColor
                'DisableForm
                StatusBar1.Panels(1).Text = "Ready"
            Else
                Exit Sub
            End If
        Case "Del"
            StatusBar1.Panels(1).Text = "Delete"
                              
                intJawab = MsgBox("Are you sure to delete this data?", vbYesNo + vbExclamation, "Delete")
                If intJawab = 6 Then 'vbYes
                rsPerusahaan.Delete
                'rsPerusahaan.Edit
                'rsPerusahaan!RS = "D"
                MsgBox "Successfully deleted."
                
                Else
                End If
                'EnableColor
                'EnableForm
                'DisableLock
                
            End
        Case "Edit"
       
       StatusBar1.Panels(1).Text = "Edit"
       Case "Exit"
            Unload Me
        
    End Select
End Sub

Last edited by v0id; 05-08-2008 at 01:54 AM.
Reply With Quote

Sponsored Links