Results 1 to 9 of 9
  1. #1
    jopi is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    20

    DLookup function in form


    DLookup function in form (see attached file)
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why do you need to lookup Prefixo_PS? Already have Prefixo in the [Espécie] combobox.


    DLookup in queries and forms/reports can be slow performers. Try this instead:

    Espécie combobox properties:

    RowSource: SELECT Espécie.ID_Esp, Espécie.Espécie, Espécie.Prefixo, Espécie.Sufixo, Esp_Pref_Suf.Espécie_PS
    FROM Espécie LEFT JOIN Esp_Pref_Suf ON Espécie.Prefixo = Esp_Pref_Suf.Prefixo_PS;

    ColumnCount: 5

    ColumnWidths: 0";6.3";0";0";0"


    MOE_final expression: =[Espécie].[Column](2) & [MOE] & [Espécie].[Column](3)


    Saving calculated data is usually a bad idea. There is no reason to save the concatenated value. Calculate it whenever needed. Saving it to field will require 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.

  3. #3
    jopi is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    20

    Only Partially working?

    Thanks for the reply. However I think it is only partially working (please see attached file). What am I doing wrong..?
    Click image for larger version. 

Name:	SubForm jpg.jpg 
Views:	31 
Size:	76.0 KB 
ID:	16570
    Attached Files Attached Files

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Sorry, I should have taken closer look at those two tables. What is each of them for? Why do they have the same data? Don't need query as RowSource after all. Can use table reference as you had but show ColumnCount as 4 and ColumnWidths as appropriate.

    Then the Prefix and Suffix should both be available for the concatenation expression. Except you are not saving the Prefix and Suffix text in Espécie table, you are saving their ID values. This was not apparent to me before because you have lookups set in tables and I saw text not ID. Setting Lookups in tables is ill-advised, especially if the lookup has alias. Review: http://access.mvps.org/access/lookupfields.htm

    I suggest you eliminate the ID fields from Prefixo and Sufixo tables and save the actual text values into Espécie table.
    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
    jopi is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    20
    Good idea..Problem solved. Thanks a lot.....!

  6. #6
    jopi is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    20

    Form field is not saving values

    Quote Originally Posted by June7 View Post
    Sorry, I should have taken closer look at those two tables. What is each of them for? Why do they have the same data? Don't need query as RowSource after all. Can use table reference as you had but show ColumnCount as 4 and ColumnWidths as appropriate.

    Then the Prefix and Suffix should both be available for the concatenation expression. Except you are not saving the Prefix and Suffix text in Espécie table, you are saving their ID values. This was not apparent to me before because you have lookups set in tables and I saw text not ID. Setting Lookups in tables is ill-advised, especially if the lookup has alias. Review: http://access.mvps.org/access/lookupfields.htm

    I suggest you eliminate the ID fields from Prefixo and Sufixo tables and save the actual text values into Espécie table.


    The form field is not saving "concatenated" values. How can I do a query based on these values, afterwards (please see attatched file)? Thank you.
    Attached Files Attached Files

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Saving calculated data requires code and should be avoided whenever possible. Calculate the concatenated value when needed.

    But if you must save, the real trick is figuring out what event to put the code in. Try the BeforeUpdate event of the subform.

    Rename the MOE_final textbox different from the field name.

    Me!MOE_final = Me.tbxMOE_final

    or

    Me!MOE_final = [Espécie].[Column](2) & [MOE] & [Espécie].[Column](3)
    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.

  8. #8
    jopi is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2014
    Posts
    20

    Calculated dield in forms

    Quote Originally Posted by June7 View Post
    Saving calculated data requires code and should be avoided whenever possible. Calculate the concatenated value when needed.

    But if you must save, the real trick is figuring out what event to put the code in. Try the BeforeUpdate event of the subform.

    Rename the MOE_final textbox different from the field name.

    Me!MOE_final = Me.tbxMOE_final

    or

    Me!MOE_final = [Espécie].[Column](2) & [MOE] & [Espécie].[Column](3)

    If I choose to always calculate (and not to save to a table), in this particular case, what should I write in the query field to get something similar to what I got in the form with : “= [Species]. [Column] (2) & [MOE] & [Species]. [Column] (3)” '? Many thanks for the help.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    By joining tables in query.

    Must change Espécie field to Number type (Long Integer).

    SELECT Esp_Pref_Suf.Espécie_PS, [Prefixo_PS] & [MOE] & [Sufixo_PS] AS MOEFinal
    FROM RelEspApt LEFT JOIN Esp_Pref_Suf ON RelEspApt.Espécie = Esp_Pref_Suf.ID_PS;
    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. Replies: 10
    Last Post: 12-27-2013, 02:54 PM
  2. Replies: 5
    Last Post: 11-17-2013, 04:20 PM
  3. DLOOKUP function
    By tariq1 in forum Programming
    Replies: 5
    Last Post: 07-17-2012, 04:22 PM
  4. DlookUp Function.
    By cap.zadi in forum Forms
    Replies: 11
    Last Post: 09-22-2011, 12:56 PM
  5. Need Help for Dlookup function
    By wasim_sono in forum Programming
    Replies: 5
    Last Post: 01-04-2006, 08:18 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