469,126 Members | 1,271 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,126 developers. It's quick & easy.

How to clone a command button action

I want to clone an action button in an Access 97 form, but have it update multiple fields in related records. The current button only updates one field.

The code I am looking at and copying/pasting to my new button is:

Expand|Select|Wrap|Line Numbers
  1.     ' update the follow-up date in the remaining members of this debtor group
  2.     Dim strSQL As String
  3.     strSQL = "update DEBTORS set [UNTL] = '" & Me.UNTL & _
  4.             "' where [DCODE] = '" & Me.DCODE & "';"
  5.     DoCmd.SetWarnings False
  6.     DoCmd.RunSQL strSQL
The UNTL field is updated in that action, but I want to update multiple fields, those being L4, PHONE, BLDG, STREET,CITY,ZIP,AREA

How do I update multiple fields by that command button action?
Oct 11 '10 #1
3 1492
nico5038
3,080 Expert 2GB
Use an "expanded" SET command like:

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblA SET A = 123, B = 456, C = "test"
  2. WHERE A <> 234
  3.  
Nic;o)
Oct 11 '10 #2
I finally found the proper syntax:

Expand|Select|Wrap|Line Numbers
  1. strSQL = "update DEBTORS set [UNTL] = '" & Me.UNTL & _
  2. "', [AREA] = '" & Me.AREA & "' [L4] = '" & Me.L4 & "', [PHONE] = '" & Me.PHONE & "', [BLDG] = '" & Me.BLDG & "', [STREET] = '" & Me.STREET & "', [CITY] = '" & Me.CITY & "', [ZIP] = '" & Me.ZIP & "' WHERE [DCODE] = '" & Me.DCODE & "';"
Just some comma placement between the fields to be updated! I knew it was simple.

Again, this was Access 97
Oct 12 '10 #3
nico5038
3,080 Expert 2GB
When you know, it's always simple :-)

Well done, stringing this much as always a daunting task.

Success with your application !

Nic;o)
Oct 12 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by Samantha Smit | last post: by
2 posts views Thread by Colin | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.