hi guys,im a newbie here.. i have a piece of coding.. but i get an error,pls help,its for my final project...:(
i have highlighted where i get an error.. pls help. if u must know i got the source code online and modified it to suit my requirements.
i have highlighted where i get an error.. pls help. if u must know i got the source code online and modified it to suit my requirements.
Code:
Option Explicit
Dim db As Database
Dim rs As Recordset
Private Sub Form_Load()
On Error GoTo ErrHandler
Set db = OpenDatabase(App.Path & "\sad.mdb")
Set rs = db.OpenRecordset("supplier", dbOpenDynaset)
Exit Sub
ErrHandler:
Dim ErrNum, ErrDesc, ErrSource
ErrNum = Err.Number
ErrDesc = Err.Description
ErrSource = Err.Source
MsgBox "Error# = " & ErrNum & vbCrLf & "Description = " & ErrDesc & vbCrLf & "Source = " & ErrSource, vbCritical + vbOKOnly, "Program Error!"
Err.Clear
Exit Sub
End Sub
[B]Private Sub cmd_add_Click()[/B]
On Error GoTo ErrHandler
Dim SupplierID, Name, Address
If txtID.Text = "" And txtName.Text = "" And _
txtAddress.Text = "" Then
MsgBox "You must enter information in for at least the supplier" _
, vbOKOnly + vbCritical, "Data Required"
ClearForm
Exit Sub
End If
SupplierID = Encode(txtID.Text)
Name = Encode(txtName.Text)
Address = Encode(txtAddress.Text)
With rs
.AddNew
!SupplierID = ID
!Name = Name
!Address = Address
.Update
End With
ClearForm
GetEntries
Exit Sub
End Sub
Private Sub Form_Unload(Cancel As Integer)
rs.Close
db.Close
End Sub
Comment