Results 1 to 6 of 6
  1. #1
    concoders is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    3

    Functions that should return the same result but do not

    I have two functions both should have the same results but they do not.


    Public Function DefaultGreeting() As String


    On Error Resume Next
    DefaultGreeting = "Dear " & [Forms]![frm_contacts]![Dear] & ":"
    End Function


    Public Function DefaultBodyText() As String
    On Error Resume Next
    DefaultBodyText = [Forms]![frm_e_mailing]![mess_text] / this equals this just pulled from a table "Dear " & [Forms]![frm_contacts]![Dear] & ":"
    End Function

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    I don't see how they can equal..
    [Forms]![frm_e_mailing]![mess_text] can be totally different than forms!frmContacts!dear

  3. #3
    concoders is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    3
    Quote Originally Posted by ranman256 View Post
    I don't see how they can equal..
    [Forms]![frm_e_mailing]![mess_text] can be totally different than forms!frmContacts!dear
    It is the same, only the second function is pulling from a table, where the first function is hard coded. I am trying to store code in a table to pull it into VBA this was an example.

  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,930
    Also don't understand how they are equal. How is the data in field [Dear] also in [mess_text]? Exactly what is [mess_text] - field name, textbox name, both?

    You mean you are storing text in a table and using code to dynamically retrieve instead of hard coding text.

    If you want to provide db for analysis, follow instructions at bottom of my post.
    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
    concoders is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    3
    this string ("Dear " & [Forms]![frm_contacts]![Dear] & ":") is in the field [mess_text] however when I do a lookup or set a variable from the form it is treated as a string not as this -> DefaultGreeting = "Dear " & [Forms]![frm_contacts]![Dear] & ":" -> this gives me Dear Concoders: the other gives me this ->"Dear " & [Forms]![frm_contacts]![Dear] & ":"


  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Yep, that's what will happen.

    What you are trying doesn't really make sense. If you need to be able to dynamically reference different forms (but the same field [Dear]) by the same code, store form name in field [mess_text] then build the reference with:

    DefaultGreeting = "Dear " & Forms.Form("[" & [mess_text] & "]").[Dear]
    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.

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

Similar Threads

  1. Return the result of a search
    By Loc in forum Programming
    Replies: 11
    Last Post: 06-12-2013, 06:23 PM
  2. Return result based on %
    By Guitarzan in forum Access
    Replies: 1
    Last Post: 08-08-2012, 09:18 AM
  3. Replies: 14
    Last Post: 02-25-2012, 02:59 PM
  4. Return DLookup result as date?
    By kman42 in forum Access
    Replies: 8
    Last Post: 04-22-2011, 11:35 AM
  5. how to return the result?
    By lamkee in forum Access
    Replies: 1
    Last Post: 08-10-2010, 10:50 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