Howdy, Stranger!

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

Categories

Displaying partial text

PringlezPringlez Member Posts: 2
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

  • llunnllunn Member Posts: 63
    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

  • compuchipcompuchip Member Posts: 273
    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
    :
    :

  • Shawn CarterShawn Carter Member Posts: 0

    ____ || http://forcoder.org || free video tutorials and ebooks about | JavaScript Python C++ Objective-C MATLAB Swift C PL/SQL Perl C# Visual Basic .NET R PHP Ruby Delphi Visual Basic Scratch Java Go Assembly Scheme Julia Alice Ada FoxPro SAS Scala COBOL Clojure LabVIEW ABAP VBScript Crystal Logo Dart ML Erlang Bash F# Hack Lua Prolog Lisp D Transact-SQL Kotlin Apex Awk Rust Fortran | _______

Sign In or Register to comment.