SQL on a button (1 Viewer)

rschultz

Registered User.
Local time
Today, 22:12
Joined
Apr 25, 2001
Messages
96
Using Access 97 I created a query that works. Then I took the SQL version of it and pasted it on a button but when I click the button nothing happens. What am I missing? Here is the code I have on the button:

Private Sub CmdRemove_City_of_Phx_from_Cost_Center_Field_Click()
Dim STRSOURCE As String
STRSOURCE = "UPDATE [SWG Import Test] SET [SWG Import Test].[Cost Center] = " & _
"IIf(Left([Cost Center],11)='City of Phx',Mid([Cost Center],13),[Cost Center]);"
end sub
 

AccessUser

Registered User.
Local time
Today, 22:12
Joined
Mar 28, 2001
Messages
35
you need to add docmd.RunSql (strsource) before the end sub
 

KDg

Registered User.
Local time
Today, 22:12
Joined
Oct 28, 1999
Messages
181
Hi,

the only problem is that you're not actualy doing anything with the string after you've set its value. To get it to run just add the line

currentdb.execute strsource

just before end sub

HTH

Drew

curse these slow fingers...

[This message has been edited by KDg (edited 06-25-2001).]
 

Users who are viewing this thread

Top Bottom