Results 1 to 15 of 15
  1. #1
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31

    Can't concatenate field with text with another field with numbers

    Hi, every1,



    I have a table with a field of numbers (PmtReceived) and another field with the currency (CUR). The latter can be USD for US dollars or EUR for euros.

    I would like to join these two fields into a single one (in a report) with CUR + PmtReceived and I have tried millions of things to no avail.

    Example:
    CUR VALUE = JOINED NEW FIELD
    USD 2,000.00 = USD 2,000.00

    Thanks in advance for any suggestion!

    lbcarvalho

  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,521
    Have you tried & as the concatenation operator?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31
    Yes, I have used the operator & millions of times.

  4. #4
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31
    Quote Originally Posted by lbcarvalho View Post
    Yes, I have used the operator & millions of times.
    I have tried this, for example: =[CUR] & [PmtReceived] but it didn't work.

  5. #5
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Have you tried COmbined:[Cur] & " " & Format([PmtReceived, "Currency")?

    Cheers,
    Vlad

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    you can use the format property for the control e.g. "USD "#,##0.00

    or you can use the format function e.g. format([pmtRecieved],"""USD ""#,##0.00")

    the function converts your value to text so use the property method if you want to refer to the original value - to total for example. In your case, because the CUR value changes you will need to use the function - something like

    [CUR] & " " & format([pmtRecieved],"#,##0.00")

    or

    Format([pmtRecieved],"""" & [CUR] & """ #,##0.00")

    for the future, comments such as 'I have tried millions of things to no avail.' without providing examples of what you have tried give the impression you haven't tried anything. It helps to know what you have tried and what failed - it may be the code you tried was wrong or right but in the wrong place.

  7. #7
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31
    I just tried you suggestion: =[CUR] & " " & Format([PmtReceived],"Currency") but when I click on the Display Mode button the fields show #Type!

  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,521
    Make sure no control has the same name as those 2 fields. Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31
    Click image for larger version. 

Name:	TYPE ERROR.PNG 
Views:	15 
Size:	12.6 KB 
ID:	39058
    This is what I am getting so far. Not sure if I made it enough clear, but it is a report I'm trying to build.

  10. #10
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31
    I've also tried this: =[CUR] & " " & Format([pmtReceived];"#,000\.00") in the Data > Control Source

    Click image for larger version. 

Name:	TYPE ERROR (2).PNG 
Views:	15 
Size:	29.8 KB 
ID:	39059

  11. #11
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31
    BTW, [MOEDA] is Portuguese for [CUR]. Sorry for the confusion, but I am in Brazil and also trying to make things easier for you guys.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Did you notice this?

    Quote Originally Posted by pbaldy View Post
    Make sure no control has the same name as those 2 fields.
    The picture shows the textbox has the same name as the field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,114
    Or even betterdo the concatenation in the report's record source (query) and use that field as the control's source.

    Cheers,
    Vlad

  14. #14
    lbcarvalho is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jul 2018
    Posts
    31
    Actually no, I had not noticed that. Thanks for pointing it out! And it really seems to have been the cause of all the trouble.

    I deleted the field and inserted it again using the Access right pane (Tools > Add Existing Fields) and inserted this: =[CUR] & " " & Format([PmtReceived];"#.###,00") and Access itself took care of the same name issue. This time it worked out fine!

    Thank you all very much!

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    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. UPDATE QUERY to Separate Numbers from Text in a Text Field
    By pjordan@drcog.org in forum Queries
    Replies: 2
    Last Post: 05-29-2015, 02:44 PM
  2. Replies: 3
    Last Post: 06-12-2014, 10:30 AM
  3. Replies: 17
    Last Post: 03-16-2014, 10:52 PM
  4. Replies: 6
    Last Post: 04-07-2011, 12:33 PM
  5. Concatenate two fields (text & number) for key field
    By Larry Elfenbein in forum Forms
    Replies: 2
    Last Post: 11-10-2005, 07:45 AM

Tags for this Thread

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