Displaying partial text

Hi Everyone,

I currently have a request for a query that only outputs part of a specified field. The request would look like the following:

Example:
Current Query output
xx-1232-er-3433
xxx-24545-5t5-98

Requested Query output
xx-1232
xxx-24545

Im not sure how to accomplish this because the length of the letter and number segments are not consistant, but they are all divide by dashes. Any help would be greatly appreciated.

Comments

  • If you are formatting your output on a form or report you can the Instr(), Left() and any one of looping structures

    : Hi Everyone,
    :
    : I currently have a request for a query that only outputs part of a specified field. The request would look like the following:
    :
    : Example:
    : Current Query output
    : xx-1232-er-3433
    : xxx-24545-5t5-98
    :
    : Requested Query output
    : xx-1232
    : xxx-24545
    :
    : Im not sure how to accomplish this because the length of the letter and number segments are not consistant, but they are all divide by dashes. Any help would be greatly appreciated.
    :

    Lee
    Moderator

  • I think this is what you mean:
    [code]
    Sub MyFunction(QueryOutput As String)
    // QueryOutput is xxxx-12345-67890
    Dim temp As String
    temp = Left$(QueryOutput, Instr(QueryOutput, "-"))
    // temp now contains xxxx-
    QueryOutput = Mid$(QueryOutput, Instr(QueryOutput, "-") + 1);
    // QueryOutput now contains 12345-67890
    temp = temp & Left$(QueryOutput, Instr(QueryOutput, "-") - 1)
    // temp is now xxxx-12345
    End Sub
    [/code]

    : If you are formatting your output on a form or report you can the Instr(), Left() and any one of looping structures
    :
    : : Hi Everyone,
    : :
    : : I currently have a request for a query that only outputs part of a specified field. The request would look like the following:
    : :
    : : Example:
    : : Current Query output
    : : xx-1232-er-3433
    : : xxx-24545-5t5-98
    : :
    : : Requested Query output
    : : xx-1232
    : : xxx-24545
    : :
    : : Im not sure how to accomplish this because the length of the letter and number segments are not consistant, but they are all divide by dashes. Any help would be greatly appreciated.
    : :
    :
    : Lee
    : Moderator
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories