Discussion Locked

using VB to export information

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am testing out VB trying to get it to export the contents of text boxes out to a Access 2000 database. I have code to view the records but I can't seem to get the save button to save a record change or save a newly added record. Here is the codeI am using.
Private Sub cmdsave_Click()
With rsproducts
If baddnew Then .AddNew
rsproducts!firstname = Text1.Text
rsproducts!lastname = Text2.Text
rsproducts!city = Text3.Text
rsproducts.Update
End With
End Sub
I have established an open connection and can see information but can't seem to save any changes. I have the ADO 2.5 library and
microsoft access 9 library as well

any suggestions??

5 replies

by shanghai sam

My guess is you have your ADO Recordset set up wrong. Try this

'Put this code where you create your Rs
With RsADO
.CursorLocation = adUseClient

.Open "SELECT F1,F2 FROM TBL_1", _
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\SomeDB.mdb", _
adOpenDynamic, adLockOptimistic

End With

Private Sub cmdSave_Click()
With RsAdo
'I assume baddnew is a public boolean
'variable
'I also assume that when your calling this
'for an update you have your Rs pointer
'at the correct record
If baddNew Then .AddNew
!F1 = CStr(Txt1.Text)
!F2 = CStr(Txt2.Text)
.Update
End With
End Sub

If you need another example let me know.
Good Luck
Neal Martinelli

This discussion is closed to new replies.