Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2007
    Posts
    19

    Unanswered: Parsing value of a tag

    Hi All

    I have a tag called ITEM_ID which stores the unique names for pieces of furniture stored in a table. All of the names have a prefix separated by a hyphen ("-"). What I need to do is extract the text prior to the hyphen (the prefix) and display it as a piece of text in a report. I have most of the report designed except for a couple of components of which this is one. Thanks in advance.

    Manuel A. Ayala

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    What does just the part before the hyphen represent, and is there a good reason to not store the two peices of information separately?

    To directly answer your question, you can use InStr() and Left() to find the location of the hyphen, and pull out just the "left" part of the id respectively.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Dec 2007
    Posts
    19
    Teddy

    How do I write the expression if the tag name is called ITEM_ID? Thanks.

    Manuel

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    F1 -> InStr()
    F1 -> Left()

    You'll want to do something that involves feeding the results o InStr() to the length argument of Left().
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    First of all and as Teddy pointed out, you should not use the hyphen ("-") as a separator as this is an arithmetic operator: whats the meaning of an expression such as "4-2" ? Use the semi-colon as separator list (";") instead.

    Now if you store several pieces of data in the Tag property of a control, one easy way to access them separately is:
    Code:
    Dim varIndex As Variant
    varIndex = Split(ctl.Tag, ";")
    Then the first element stored in the Tag property can be accessed as:
    Code:
    TagElement1 = varIndex(0)
    The second element becomes:
    Code:
    TagElement2 = varIndex(1)
    and so on...
    Have a nice day!

  6. #6
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    I think they're using "tag" and "field name" interchangably.

    Correct me if I'm wrong Manuel.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  7. #7
    Join Date
    Dec 2007
    Posts
    19
    I currently have a table with a field called ITEM_ID and the values stored in this field are extracted from an AutoCAD drawing and dumped in the table. The values all have a prefix of 1 to 2 characters separated by a hyphen. The prefix is used to identify whether the item is a table (T), a bookcase (B), a chair (C) and so on. At the top of each printed report I need to identify what category the item is from, which happens to correspond to the letter prefix. I hope this description is helpful. Thanks.

    Manuel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •