Results 1 to 10 of 10
  1. #1
    excellenthelp is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    93

    =Trim with value from a combobox?

    Hi Accessers,



    How should I edit the code below to reflect the correct value using Trim?

    Code:
    =Trim([PhyCity] & ", " & [PhyState] & " " & [PhyPostalCode])
    I want the result to show 'TX' instead of '5' (which is the ID of the record).

    Help!

  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,652
    Try
    [PhyState].Column(1)

    or the appropriate zero based column number.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    excellenthelp is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    93
    pbaldy,

    Thank you for the suggestion. It does, unfortunately, not work. After I type [PhyState].Column(1), it automatically turns to [PhyState].[Column](1) and spits out #NAME? on the report.

    Next suggestion? I will continue to do some research on this as well.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Does the combo include the relevant field in the row source? Is the column count property of the combo correct?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    excellenthelp is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    93
    Yes, there are only two columns: first with ID and second with States.

    However, there is no comboboxes on the report. I am using the TRIM function. Below is a quick snapshot of the report:
    Click image for larger version. 

Name:	Capture.PNG 
Views:	10 
Size:	17.4 KB 
ID:	18808

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I'm confused since the thread title mentions a combo. For a report, I'd expect it to be based on a query that joins the main table to the table with states, enabling you to return the text value as a field for the report. Your formula would reference that field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    excellenthelp is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    93
    Ahh pbaldy, my bad. I was referencing a combo for a reason! The query the report is based on is:

    Code:
    SELECT tblAIA_ACAList.ACAName, tblAIA_ACAList.Acronym, tblAIA_ACAList.PhyAddress1, tblAIA_ACAList.PhyAddress2, tblAIA_ACAList.PhyCity, tblAIA_ACAList.PhyState, tblAIA_ACAList.PhyPostalCode, tblAIA_ACAList.PhyCountry, tblAIA_ACAList.WebsiteFormatted, tblAIA_ACAList.PublicEMail, tblAIA_ACAList.PublicPhone, tblAIA_ACAList.Contact1, tblAIA_ACAList.Contact1EMail, tblAIA_ACAList.AccredStatus, tblAIA_ACAList.NOPAccredDoc, tblAIA_OperatingLocationsAccredScopes.USStatesList.ValueFROM (tblSupport_USStatesList INNER JOIN tblAIA_ACAList ON tblSupport_USStatesList.ID = tblAIA_ACAList.PhyState) INNER JOIN tblAIA_OperatingLocationsAccredScopes ON tblAIA_ACAList.ID = tblAIA_OperatingLocationsAccredScopes.ACAID
    WHERE (((tblAIA_ACAList.AccredStatus)=1 Or (tblAIA_ACAList.AccredStatus)=2));
    Hope this helps?

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I would assume there's a field in tblSupport_USStatesList that contains the text you want. Add that field to the query if it isn't already and reference that field in your formula.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    excellenthelp is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Mar 2014
    Posts
    93
    Ah it turned out you were right, pbadly. it was my query. I just needed to redo it and it works now by fixing the row source, bound column and number of columns and its widths.

    Thanks!!!

    Marking this as SOLVED.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Glad you got it working!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Trim!
    By redbull in forum Programming
    Replies: 9
    Last Post: 11-06-2012, 06:01 AM
  2. Trim vba
    By shexe in forum Access
    Replies: 5
    Last Post: 11-16-2011, 10:20 AM
  3. Trim value
    By dada in forum Programming
    Replies: 5
    Last Post: 09-02-2010, 11:01 PM
  4. Need Help with TRIM command
    By rbfarley in forum Reports
    Replies: 3
    Last Post: 01-08-2010, 02:03 PM
  5. Trim
    By JMantei in forum Forms
    Replies: 1
    Last Post: 06-20-2006, 02:06 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