SQL with strVarible

silentwolf

Well-known Member
Joined
May 14, 2008
Messages
1,216
Office Version
  1. 2016
Hi guys,

something simple for you I am pretty sure )

VBA Code:
    Dim db As DAO.Database
    Dim tbd As DAO.TableDef
    Dim strSQL As String
    Dim strTable As String
    
    strTable = "Neu"
    
    Set db = CurrentDb
            
    Set tbd = db.TableDefs(strTable)
    
'this is ok when I use the Query Builder...
    strSQL = "UPDATE Neu SET Neu.Zahlungsreferenz = [Neu].[ZahlRef] " & _
                "WHERE (((Neu.Zahlungsreferenz)=""x"") AND ((Neu.ZahlRef)<>""""));"

'How this need to be changed to be able to use the strTable Varible?            
    strSQL = "UPDATE " & strTable & " SET [Zahlungsreferenz] = [ZahlRef] " & _
              "WHERE (([Zahlungsreferenz])=""x"") AND [ZahlRef]<>""));"

    db.Execute strSQL
    
    Set db = Nothing

Can someone please let me know how does this code need to be changed the strSQL with the strTable varible?

Thanks for your help )
 
If the idea is to simply remove all the parentheses I would certainly give the thumbs up...
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi guys I will check when I find time but when I did debug it it gave me an error.
I will look into it a bit closer thanks for the moment!

Just need to get some other things sorted first so I wil get back to you ..when I got a better answer.

Thanks
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top