HI,
I have created a form with various text boxes around.... i want as soon as sombody will click on the save button the data will be saved in a database called mydb.mdb......i m a very newbie to this vb....kindly help.....i have written code as below.....but geting an error of "c:\incidentrep ort\incidentrep ortmydb.mdb not found"
Whereas i am keeping the database in the same path as the error is coming.
Private Sub cmdAdd_Click()
Dim conec As New ADODB.Connectio n
Dim rs As New ADODB.Recordset
conec.Connectio nString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source ='" & App.Path & "MyDB.mdb'"
conec.CursorLoc ation = adUseClient
conec.Open
rs.Open "select * from clients where Client_Id='" & txtUserName.Tex t & "'", conec, adOpenKeyset, adLockOptimisti c
If txtUserName.Tex t = "" Then
MsgBox "Please fill the Client Id Number", vbCritical
Else
With rs
' Search for identical/matching STUDENTCODE
If rs.RecordCount = 0 Then '---> If there's no identical/matching Clientid, then save as new data
.AddNew
End If
!clientid = txtUserName.Tex t
!clientname = txtName_First.T ext
!clientADDRESS = txtName_Last.Te xt
.Update
End With
End If
End Sub
kindly help me in geting this minor problem resolved.
when i debug error gets highlighted in cn.open
I have created a form with various text boxes around.... i want as soon as sombody will click on the save button the data will be saved in a database called mydb.mdb......i m a very newbie to this vb....kindly help.....i have written code as below.....but geting an error of "c:\incidentrep ort\incidentrep ortmydb.mdb not found"
Whereas i am keeping the database in the same path as the error is coming.
Private Sub cmdAdd_Click()
Dim conec As New ADODB.Connectio n
Dim rs As New ADODB.Recordset
conec.Connectio nString = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source ='" & App.Path & "MyDB.mdb'"
conec.CursorLoc ation = adUseClient
conec.Open
rs.Open "select * from clients where Client_Id='" & txtUserName.Tex t & "'", conec, adOpenKeyset, adLockOptimisti c
If txtUserName.Tex t = "" Then
MsgBox "Please fill the Client Id Number", vbCritical
Else
With rs
' Search for identical/matching STUDENTCODE
If rs.RecordCount = 0 Then '---> If there's no identical/matching Clientid, then save as new data
.AddNew
End If
!clientid = txtUserName.Tex t
!clientname = txtName_First.T ext
!clientADDRESS = txtName_Last.Te xt
.Update
End With
End If
End Sub
kindly help me in geting this minor problem resolved.
when i debug error gets highlighted in cn.open
Comment