Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update runs without error - does not update

Status
Not open for further replies.

pochta

Programmer
Dec 4, 2003
7
US
I have been using VB6 to read data from Access. Now I want to write into the data base. I have set up a simple table with fields to test:

ID Name Number Mark

I have populated 5 records with random contents. In VB6 I have a form with one Command Button and one Text Box. The Text Box is bound to the Number field of the table. The following code is under the button:

Public Sub Command1_Click()


lnkData.CommandType = adCmdUnknown

lnkData.RecordSource = "UPDATE Test1 SET Test1.Number=123 WHERE ID=3"

lnkData.RecordSource = "SELECT Number FROM Test1 WHERE ID=3"

lnkData.Refresh


End Sub


The SELECT statement reads what is actually in the field but the UPDATE statement never changes it.

The routine was orginally Private. When I changed it to Public the Update worked the first time through. AArrrrrgh! It does not make sense.

Help!
 
1st, you can't use "Update" sqls as a recordsource.
Next lnkData, does it have a connection associated with it?
If it does, then the

"UPDATE Test1 SET Test1.Number=123 WHERE ID=3"
would be handled by

SomeConnection.execute "UPDATE Test1 SET Test1.Number=123 WHERE ID=3"
 
vbajock,

Thanks.

lnkData is the name of an Adodc tool that is connected to the access table. It is the same tool used for the SELECT statement.

Tried Execute and got the 'method or data member not found' error message. The term execute is not in the VB help index and the word does not appear in the selection list after I type lnkData.

 
You'll find execute listed as a method of the ADO connection object. You may want to pick up a book by WROX Press, "Beginning ADO 2.6", which is a really great desktop reference and explanation of ADO that is much handier then the help file. If you can post the code that declares and sets the lnkData object I can perhaps give you some more help with your current problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top