|
||||||
| Visual Basic Programming Discussion forum for Visual Basic, an event driven programming language and associated development environment from Microsoft for its COM programming model. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 12:54 AM. |
| Sponsored Links |
|
|
|
|||||
|
Code:
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
__________________
[TRUTH] TcM is the best moderator ever! [/TRUTH] "Valid XHTML is like sex - everybody claims to have the same goal, but everybody has their own tricks and results vary wildly." To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| Xav | ........ | 1024.41 |
| MeTh0Dz|Reb0rn | ........ | 974.08 |
| morefood2001 | ........ | 850.04 |
| John | ........ | 841.93 |
| WingedPanther | ........ | 661.52 |
| marwex89 | ........ | 575.59 |
| Brandon W | ........ | 456.18 |
| chili5 | ........ | 292.12 |
| orjan | ........ | 187.41 |
| Steve.L | ........ | 181.88 |
Goal: 100,000 Posts
Complete: 79%