Based on previous tutorial , here script to give procedure input, update, and erase records in Ms Access 2010.
Save Procedure
---
Private Sub save()
If Trim(Text(1).Text) = "" Or Trim(Text(1).Text) = " " Then
MsgBox ("ID Distributor is empty, ID Distributor must not empty")
Cancel = True 'if empty, then cancel or do nothing
Text(1).SetFocus
Else
Call opendb
Call delete 'this is used to erase the data, and then replace with the new one (update function)
xSQL = "insert into distributor (id_distributor,distributor,"
xSQL = xSQL & "discount)"
xSQL = xSQL & " values "
xSQL = xSQL & "('" & Text(1).Text & "',"
xSQL = xSQL & "'" & Text(2).Text & "',"
xSQL = xSQL & "'" & Text(3).Text & "')"
oConn.Execute xSQL
If Err = 1 Then
MsgBox ("Failed,..!!!") 'if error, then show message
Else
Call clear 'if success all text box clean up, and show message
MsgBox ("Successfull,..!!!")
Text(1).SetFocus
End If
End If
End Sub
---
Delete Procedure
---
Private Sub delete()
If Trim(Text(1).Text) = "" Or Trim(Text(1).Text) = " " Then
MsgBox ("ID Distributor is empty, ID Distributor must not empty")
Cancel = True
Text(1).SetFocus
Else
Call opendb
xSQL = "delete from distributor "
xSQL = xSQL & " where "
xSQL = xSQL & " id_distributor = '" & RTrim(Text(1).Text) & "' "
oConn.Execute xSQL
If Err = 1 Then
MsgBox ("Failed,..!!!")
Else
Call clear
MsgBox ("Successfull,..!!!")
Text(1).SetFocus
End If
End If
End Sub
---
Thursday, September 26, 2013
Create a VB6 script to manipulate records in Ms Access 2010 database
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment