Results 1 to 4 of 4
  1. #1
    smikkelsen is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    60

    VBA in variables

    I have a text field allowing users to enter custom notes that can be selected from a combo box on a different form (allowing them to use the note over and over without typing it each time).



    I want the user to be able to access some field contents in their notes.

    For example a user might type this note:

    Sent Bob an email to follow up on progress.

    I would like them to be able to write a note like this:

    Sent [customer] an email to follow up on progress.

    so that the [customer] field will be entered.

    Here is the code I have:


    Code:
     
    Dim temp As String
    temp = DLookup("[Note]", "Local_CustomNotes", "[Title] = '" & [cmb_CustomNote].Column(1) & "'")
    MsgBox temp
    [Text0] = temp
    the dlookup will grab the custom note that the user has saved and enter it into the text0 field.

    I thought if the user typed something like this:
    "Sent " & [customer] & " an email to follow up on progress."
    in the custom note area, it could do what I wanted. But instead it looks at all of it as literal string.

    Is there an easy way to accomplish this?

    Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    One way that comes to mind (I'm assuming the customer is on the form):

    temp = Replace(temp, "[Customer]", Me.TextboxWithName)

    replacing TextboxWithName with the name of the textbox containing the name you want to use.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    smikkelsen is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    60
    That is a great idea. There are probably 50 fields that they could possibly use in their notes. Is there a more dynamic way of doing it? If not I can just code a replace for every possibility.

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    You should think a way to put customer name in the notes at the time user setup the notes.
    you can not rely on the user type in the notes following the program syntax. e.g. if you want "Sent " & [customer] & " an email to follow up on progress."
    but the user miss some " or other thing, your program will run into an error.

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

Similar Threads

  1. Shell with Batch Variables
    By robbyaube in forum Programming
    Replies: 2
    Last Post: 12-19-2019, 11:06 AM
  2. Passing variables to a Word Doc.
    By techexpressinc in forum Forms
    Replies: 2
    Last Post: 09-16-2010, 01:04 PM
  3. Variables in Forms
    By NewDeveloper in forum Forms
    Replies: 1
    Last Post: 06-20-2010, 08:04 AM
  4. Append Query using variables
    By hawg1 in forum Queries
    Replies: 2
    Last Post: 06-09-2010, 08:59 AM
  5. sql in vb variables
    By emilylu3 in forum Programming
    Replies: 3
    Last Post: 03-04-2006, 01:26 PM

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