Click to See Complete Forum and Search --> : SQL.... UPDATE statment
xstopx81
Aug 15th, 2000, 04:07 PM
view this codes and tell me what i did wrong. this update statement don't do anything
datGrouping.RecordSource = "UPDATE [Contacts] SET [Group] = '" & tempstring & "'"
datGrouping.RecordSource = "SELECT * FROM [Contacts] ORDER BY CompanyName"
datGrouping.Refresh
parksie
Aug 15th, 2000, 04:22 PM
Try using the Database.Execute method for 'action' queries.
JHausmann
Aug 15th, 2000, 04:42 PM
Originally posted by xstopx81
view this codes and tell me what i did wrong. this update statement don't do anything
datGrouping.RecordSource = "UPDATE [Contacts] SET [Group] = '" & tempstring & "'"
datGrouping.RecordSource = "SELECT * FROM [Contacts] ORDER BY CompanyName"
datGrouping.Refresh
Easy. The second setting of datGrouping.RecordSource overwrites the first.
xstopx81
Aug 17th, 2000, 04:51 PM
thanks for replying guys but your suggestions are not working. I have used execute command and also tried deleting the select statment. Both method does not seem to work
Tonatiuh
Aug 18th, 2000, 01:15 PM
Maybe you forgot the WHERE statament in the first line. The statment as it appears will not know what rows to update. If you include a "WHERE [PrimaryKey]='SomeValue'", it could work.
Good Look!
[Edited by Tonatiuh on 08-18-2000 at 02:18 PM]
parksie
Aug 18th, 2000, 01:25 PM
If you leave out the WHERE clause, it updates all of them. Using the Execute method with an Update query worked for me.
Try:
DB.Execute "UPDATE Contacts SET Group = '" & tempstring & "'"
datGrouping.RecordSource = "SELECT * FROM Contacts ORDER BY CompanyName"
datGrouping.Refresh
xstopx81
Aug 18th, 2000, 01:46 PM
hey thanks for replying... parksie, in ur coding... what's DB? cant i just make it as datgrouping.database.execute? help
parksie
Aug 18th, 2000, 01:50 PM
I just used DB as a placeholder for the original Database object.
xstopx81
Aug 18th, 2000, 03:31 PM
thanks parksie ... your coding works!!!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.