Results 1 to 12 of 12
  1. #1
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27

    concatenation for a field, keeping the masking data

    I have a nice laid out query, trying to keep the masking fields.
    aka !000\V/00"Ph"/00"Hz";;_


    sample, 480V/60Ph/03Hz

    when I use my query to concatenate the fields, it comes out as 4806003

    how is it possible to keep the fields with the masked inputted data? with the !000\V/00"Ph"/00"Hz";;_

    sql
    [cat_tbl.cat_name] & (","+[subcat_tbl.sub_cat_name]+",") & (" "+[copy of parts_tbl.parts_material]+",") & (" "+[copy of parts_tbl.parts_specification]+",") & (" "+[manuft_tbl.manufact_name]+",") & (" "+[copy of parts_tbl.manufact_model_no]+",") & (" "+[copy of parts_tbl.parts_finish]+ ",") & (" "+[electrical_data_tbl.electrical_data]) &"." AS full_description,

    it fits into electrical data field and table,

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If you want to save the constant characters, set the mask as:

    !000\V/00"Ph"/00"Hz";0;_

    Don't use + as concatenation operator. Always use & for concatenation. I expect all those parentheses will cause an issue.

    Why do you want to concatenate fields?
    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
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27
    putting all fields in one column for reporting.
    the + is the iif statement.
    it works great, the parentheses do not cause a problem.
    The problem lies is when it is being carried over from either the table.field data or query.field
    thank you for your quick response. I will try to see if this works.

  4. #4
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27
    FYI Ive put the above in to a query in the input mask field.
    It works, but again how to get that value carried over into my concat field. is it possible to make a field in a query, and then again query that same field over or a subqyery?

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by finsmith View Post

    ...putting all fields in one column for reporting...
    If you actually want to do this for a Report, you'd be better of doing the concatenation in the Report, rather than in the Query.

    Many things done in Queries do not carry through to Reports simply because the capability is already available to Reports.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    If you set the InputMask property to save input with the constant characters then that is the data in the table and will carry through. However, changing the InputMask property now will not change data already in the table. Need to fix the existing data. Even better might be to put those three values in separate fields.
    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.

  7. #7
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27
    ive tried other things like mytbl: [electrical_data] (with the field masked) ( masked in the query and not the table)
    and then called in the field again newmytbl: [mytbl] && [as_full_description] and it still gives the output as 4806003

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Must set the InputMask property of textbox on form in order to save the input data with the constant characters. Anywhere else is just formatting and does not alter data in table (unless is used in UPDATE or INSERT sql action or in code to populate a field of recordset) and does not carry through SELECT queries when the field is used in an expression. Otherwise, set format in the final query that is the RecordSource for report or put the concatenation expression in textbox.

    Even if the parens aren't causing issues, they aren't needed. Still better to use & for concatenation operator instead of +. And you are doing more concatenation than necessary.

    [cat_tbl.cat_name] & ", " & [subcat_tbl.sub_cat_name] & ", " & [copy of parts_tbl.parts_material] & ", " & [copy of parts_tbl.parts_specification] & ", " & [manuft_tbl.manufact_name] & ", " & [copy of parts_tbl.manufact_model_no] & ", " & [copy of parts_tbl.parts_finish] & ", " & [electrical_data_tbl.electrical_data] & "." AS full_description

    I still think would be better to have data in separate fields: Volts, Phase, Hertz.
    Last edited by June7; 01-24-2013 at 06:41 PM.
    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.

  9. #9
    finsmith is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    27
    I've been using the + as the If statement. There may not be data in the field. I want it to skip over that field.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Never seen this technique. Seems to me you could end up with extraneous comma in the string, such as if the the last item is null.
    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.

  11. #11
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by June7 View Post

    ...Never seen this technique. Seems to me you could end up with extraneous comma in the string, such as if the the last item is null...
    This is a much used technique for concatenation where Spaces and/or Delimiting Characters are used and where there may be Nulls. The whole purpose of the technique, if used properly, is to not include inappropriate spaces or commas or periods. With this example

    Code:
    CompleteName = [FirstName] & " " & ([MidInitial] + ". ") & [LastName]

    Values of Xaviar, F and Cugat

    will generate

    Xaviar F. Cugat

    while Values of Xaviar and Cugat (with no middle initial)

    will generate

    Xaviar Cugat (no period or unneeded, extra space)

    By using the plus sign to concatenate the MidInitial, the following period and space, and because adding anything to a Null value generates a Null, the bit of code

    & ([MidInitial] + ". ") &

    will only concatenate the period and the following space if MidInitial is not Null. If it is Null, period and the following space will be omitted.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Never seen but I understand and like, however, from what I can see of the OP's expression could end up with:

    value1, value2, value3, value4, value5, value6, value7,.
    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: 1
    Last Post: 01-21-2013, 02:08 PM
  2. field concatenation on a form
    By theosgood in forum Forms
    Replies: 3
    Last Post: 06-04-2012, 04:55 PM
  3. Keeping field contents if a source changes
    By gafferuk in forum Access
    Replies: 3
    Last Post: 12-28-2011, 05:39 AM
  4. Field concatenation
    By Trojnfn in forum Access
    Replies: 1
    Last Post: 10-10-2011, 05:56 PM
  5. Memo Field Not Keeping Data
    By maintt in forum Forms
    Replies: 1
    Last Post: 08-12-2010, 05:55 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