Jump to content

Need help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
yonghan

yonghan

    Learning Programmer

  • Members
  • PipPipPip
  • 99 posts
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..
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

Edited by v0id, 07 May 2008 - 09:54 PM.


#2
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
Sorry, I don't follow. What's the problem?
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#3
yonghan

yonghan

    Learning Programmer

  • Members
  • PipPipPip
  • 99 posts
The problem is that when i have deleted the only data,the program automatically closed..Are there a way so it won't be closed automatically after i delete the data?Thanks a lot..

#4
gaylo565

gaylo565

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 268 posts
looks like there is an extra end in your del case right at the end of the case. dont know if this is causing the problem but i bet its not helpin

#5
Xav

Xav

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 13,118 posts
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
                
            [B]End[/B]

You've included the word End at the end. Of course it's going to close - that's what the End statement does!
Jordan said:

Good members, like yourself, stick around and post for ages to come!
Mr. Xav | Blog | Forums

#6
yonghan

yonghan

    Learning Programmer

  • Members
  • PipPipPip
  • 99 posts
ok,thanks a lot..