Results 1 to 8 of 8
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Combine Code

    I'm having difficulty combining 2 codes:


    Nets = [OS::SW1] [GARS1::GARS2]

    1Rad2: IIf(Not IsNull([Nets]),Mid([Nets],InStr(1,[Nets],"]")+3),"") - Output = GARS1::GARS2]



    Rad2: Left([1Rad2],Len([1Rad2])-1) - Output = GARS1::GARS2

    I am paring down a string not made by me.

    Thanks
    Last edited by Thompyt; 11-19-2016 at 10:55 AM.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    This can't be real code.

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Why can it not be? I'm trying to combine 2 columns in a query into 1.

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2013 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I'm with Ranman on this - but to make strings with multiple bits and pieces keep putting "&" between each one.

  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 Thompyt View Post
    Why can it not be?
    Because

    Nets = [OS::SW1] [GARS1::GARS2]

    means absolutely nothing in Access VBA! Explain what each of these components are

    Nets
    OS
    SW1
    GARS1
    GARS2

    and how you want to combine them.

    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
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    ALLCON,
    NETS is a complete string from another source. It isn't the code part. Missinlinq has it the closest. That is exactly what I am trying to do. Break it down into the different parts

    1Rad2: IIf([Nets]<>"",Mid([Nets],InStr(1,[Nets],"]")+3),"")

    You get the out put of:
    GARS1::GARS2]

    The second is to remove the final character "]"

    Rad2: Left([1Rad2],Len([1Rad2])-1)

    Its output is: GARS1::GARS2


    I was wanring to combine both sets into 1 code line. putting a & between them would be:

    GARS1::GARS2]GARS1::GARS2

    My intent is to have four columns in the query with code to break it all down into

    "[OS::SW1] [GARS1::GARS2]"

    Col1: R1CH1: IIf([Nets]<>"",Mid(Left([Nets],InStr([Nets],":")-1),2,20),"") gets you "OS"
    Col2:
    R1CH2: IIf([Nets]<>"",Mid(Mid(Left([Nets],InStr([Nets],"]")-1),2,20),InStr(1,[Nets],":")+1)) gets you "SW1"
    Col3: "GARS1"
    Col4: IIf([Nets]<>"",Replace(Mid([Nets],InStrRev([Nets],":")+1),"]","")) gets you "GARS2"

    I am working on the others to be able to do it in 1 column each.Right now I need to have a base to start.

    Rad1: IIf(Not IsNull([Nets]),Mid(Left([Nets],InStr([Nets],"]")-1),2,20),"") - That is: "OS::SW1" for the 1st Bracketed Set.

    The Original Post is for the second bracketed data set: "[GARS1::GARS2]"

  7. #7
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    my understanding is you have a string such as "[OS::SW1] [GARS1::GARS2]" which is called Nets and you want to extract the bit highlighted in red


    If this is correct, try

    Rad2:iif(isnull([Nets]),"",replace(mid([Nets] ,instrrev([Nets] ,"[")+1),"]",""))

  8. #8
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Thanks AJAX what I was looking for. I did have the replace in there before, but instrrev I'll have to look into.

    Thanks

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-22-2016, 02:37 AM
  2. Replies: 5
    Last Post: 08-29-2016, 04:33 AM
  3. Combine data
    By DSM1957 in forum Queries
    Replies: 1
    Last Post: 07-16-2012, 04:51 AM
  4. Code to combine report filter and date range
    By rhubarb in forum Reports
    Replies: 17
    Last Post: 10-28-2011, 03:08 PM
  5. need to combine two fields
    By jwallace203 in forum Access
    Replies: 1
    Last Post: 07-29-2011, 07:11 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