Results 1 to 4 of 4

InStr not as expected

  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,118

    InStr not as expected

    In following segment of code, the Pop-up form "frmWhichBE" prompts the user to choose between a "Business" or "Personal" back-end database. The set of TableDefs are that same in both back-ends so the code is simply determining which BE is current versus which BE the user wants. The BE's are named to include .......Data(Business).mdb or .......Data(Personal).mdb. The InStr function returns zero even when there's a match. I have examined the values of strMode (Global string variable) and the value of strCurLinkBE in Debug to insure that the value of strMode is either contained in strCurLinkBE or it is not. (The two MsgBox statements are just a part of verifying code functionality at the current stage of code development.)

    I'm missing something?



    Code:
    If bolPer = True And bolBus = True Then
        intConfig = 3
        DoCmd.OpenForm "frmWhichBE", acNormal, , , , acDialog            'Show user option
        strCurLinkDB = CurrentDb.TableDefs("tblRegister").Connect        'Current BE DB?
        If Nz(InStr(1, strMode, strCurLinkDB, vbTextCompare)) = 0 Then   'User chose strMode
            MsgBox "Okay, we'll re-link to " & strMode
        Else
            MsgBox "We're already linked to " & strMode
        End If
    End If

  2. #2
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,118
    Good grief! It would help if I didn't have the String1 and String2 expressions reversed!

  3. #3
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    18,978
    The computer should be smart enough to know what you meant.
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,118
    I thought so as well

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

Similar Threads

  1. INSTR Help
    By scubaman63 in forum Queries
    Replies: 1
    Last Post: 08-02-2018, 06:43 AM
  2. InStr Help
    By MTSPEER in forum Programming
    Replies: 18
    Last Post: 09-07-2017, 06:34 AM
  3. Replies: 2
    Last Post: 04-07-2016, 06:19 AM
  4. Left instr help
    By tmcrouse in forum Forms
    Replies: 2
    Last Post: 05-12-2015, 07:47 AM
  5. IIF with instr
    By yoili in forum Reports
    Replies: 2
    Last Post: 01-22-2013, 12:32 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
  •  
Tech Forums: Microsoft Office Forums