ADO wont update table?

K

kubotakid

Dim dbConn As ADODB.Connection
Dim recSet As ADODB.Recordset

Set dbConn = CurrentProject.Connection
Set recSet = New ADODB.Recordset
recSet.CursorLocation = adUseServer
recSet.CursorType = adOpenKeyset
recSet.LockType = adLockOptimistic
recSet.Open "
", dbConn, , , adCmdTable

recSet.AddNew ' Start a new record
recSet!des = Me.IMAGEFILE
recSet!Size = Me.PRODUCT
recSet.Update ' Post the new record
recSet.Close
Set recSet = Nothing
dbConn.Close


This is from a comand button. It works to add a record but it does not
update the table in the subform. after closing the form I see the data in
the table after re opening it. How do I make it update after the this code.
I've read the the ADO needs to be set to nothing is the above right>
 
K

kubotakid

Figued it out. just had to add requery subform after the close statement.
Me.quote_main_subform.Requery
Dim dbConn As ADODB.Connection
Dim recSet As ADODB.Recordset

Set dbConn = CurrentProject.Connection
Set recSet = New ADODB.Recordset
recSet.CursorLocation = adUseServer
recSet.CursorType = adOpenKeyset
recSet.LockType = adLockOptimistic
recSet.Open "
", dbConn, , , adCmdTable

recSet.AddNew ' Start a new record
recSet!des = Me.IMAGEFILE
recSet!Size = Me.PRODUCT
recSet.Update ' Post the new record
recSet.Close
Set recSet = Nothing
dbConn.Close

This is from a comand button. It works to add a record but it does not
update the table in the subform. after closing the form I see the data in
the table after re opening it. How do I make it update after the this code.
I've read the the ADO needs to be set to nothing is the above right>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top