Results 1 to 6 of 6
  1. #1
    riggsdp is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    25

    Storing string variables in table and calling from VBA with correct insertions

    Is it possible to have a string with variables stored in a table, then assign that field's content to a variable in vba and have it insert the correct information?



    For example, if I store the following in a table:

    Code:
    "Notice of Receipt: For Review & Comment - " & frmName.Contract_Number.Column(1) & ", " & frmName.Delivery_Task_Order.Column(1) & ", CDRL " & frmName.CDRL_Number.Column(1)
    how do I assign it to a variable in vba so that it pulls the data from the form, inserts it into the string, prints correctly, and looks like the string below on the form?

    Code:
    Notice of Receipt: For Review & Comment - W58RGZ-13-D-0245, T.O. 0007, CDRL A001
    I already know that this doesn't work:

    Code:
    msgSubject = DLookup("Subject", "tblEmailCases", "Case=" & emailCase)
    and just outputs the exact string from the table.

    TIA
    dar

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Can reference form controls in a query. Your syntax is wrong. And query object cannot handle Column(x) reference.

    Why do you need VBA?

    What do you mean by print - paper copy?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    riggsdp is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2014
    Posts
    25
    Just printing it to another form. We have security settings that won't allow me to send the text to Outlook so I have it output to a form where we copy and paste it into Outlook. I already have this working by putting all the strings into my VBA code but I've been asked to add additional options and was trying to streamline it so I didn't have to add another 100 lines of code.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    So is your question answered?

    Why would you have to add 100 lines of code?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Check out the Eval() function. It should do what you want:

    msgSubject = Eval(DLookup("Subject", "tblEmailCases", "Case=" & emailCase))
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Will have to change "frmName.Contract_Number.Column(1)" to "Forms!frmName.Contract_Number.Column(1)"

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

Similar Threads

  1. Storing an object in a table
    By Paul H in forum Programming
    Replies: 2
    Last Post: 08-26-2013, 07:28 AM
  2. Replies: 5
    Last Post: 12-22-2012, 01:36 PM
  3. Replies: 3
    Last Post: 07-26-2012, 03:09 PM
  4. Replies: 3
    Last Post: 04-23-2012, 12:06 AM
  5. Replies: 2
    Last Post: 12-23-2011, 08:22 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