Results 1 to 3 of 3
  1. #1
    newbie30 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2017
    Posts
    15

    Passing the userinput from the form in a xml

    Hi All,

    Am trying to send some data wrapped in a SOAP API request.

    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <UpdateReg xmlns="http://www.cessoftware.co.uk/">
    <RegKey>712441211</RegKey>
    <ExpiryDate> </ExpiryDate>
    <OnStop>0</OnStop>
    <AutoRenew>1</AutoRenew>
    <Email>test@test.co.uk</Email>
    </UpdateReg>
    </soap:Body>
    </soap:Envelope>

    This works fine and the website data gets updated. However I want to pass the values of the xml dynamically based on what my subform has.

    I tried to store the variables from the form

    RegKey = Me.RegKey_subform1.Form!RegKey
    ExpiryDate = Me.RegKey_subform1.Form!ExpiryDate
    OnStop = Me.RegKey_subform1.Form!OnStop
    AutoRenew = Me.RegKey_subform1.Form!AutoRenew


    and want to pass those variables in the xml something like this:

    sEnv = "<?xml version=""1.0"" encoding=""utf-8""?>"
    sEnv = sEnv & "<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
    sEnv = sEnv & "<soap:Body>"
    sEnv = sEnv & "<UpdateReg xmlns=""http://www.cessoftware.co.uk/"">"
    sEnv = sEnv & " <xsi:variable name="RegKey" select="RegKey" />
    sEnv = sEnv & " <xsi:variable name="ExpiryDate" select="ExpiryDate" />
    sEnv = sEnv & " <xsi:variable name="OnStop" select="OnStop" />
    sEnv = sEnv & " <xsi:variable name="AutoRenew" select="AutoRenew" />
    sEnv = sEnv & " <Email>test@test.co.uk</Email>"


    sEnv = sEnv & "</UpdateReg>"
    sEnv = sEnv & "</soap:Body>"
    sEnv = sEnv & "</soap:Envelope>"


    But that doesn't work. Is the approach of passing variables right? How do I get to pick the values and send it in the xml. Please help.


    Thanks
    Newbie

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,158
    You would need to concatenate the value into your XML string I believe, so one line would look something like ;
    Code:
    sEnv = sEnv & " <xsi:variable name="RegKey" select=""" &  RegKey & """ />"


    If you add a Debug.Print sEnv at the end of your code you will see the actual string as it's constructed .

    You may need to use triple quotes """ throughout your string to escape the single quotes around the values.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    newbie30 is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2017
    Posts
    15
    Thank you Minty, That made my day.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 17
    Last Post: 02-25-2018, 02:37 AM
  2. passing a value from one form to another
    By Khalil Handal in forum Forms
    Replies: 6
    Last Post: 12-05-2017, 11:07 AM
  3. Replies: 5
    Last Post: 11-18-2016, 10:27 AM
  4. passing value to new second form
    By englek in forum Forms
    Replies: 2
    Last Post: 08-08-2011, 01:40 PM
  5. Passing value from one form to another
    By Molly152 in forum Forms
    Replies: 4
    Last Post: 11-16-2010, 11:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums