+ Reply to Thread
Results 1 to 3 of 3

Not sure why this query does not work

  1. #1
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Not sure why this query does not work

    Hi,

    I'm trying to activate a CommandButton next to a field as late in the writing of the string as possible.
    He is typing out his email address and for some reason this does not work:

    If Len(TextBox8.Value) + Len(TextBox7.Value) + TextBox5.Value = TextBox4.Value Then
    CommandButton2.Enabled = True
    End If

    TextBox8 is a string
    TextBox7 is a string
    TextBox5 is a number
    TextBox4 is a number

    TextBox8 is the string after the "at"
    TextBox7 is the string before the "at"
    TextBox5 is the count of "at" in the email as a number
    TextBox4 is the numeric length of the whole (incl. the "at" symbol) email.
    Last edited by Michael Island; 04-08-2020 at 02:49 PM.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Not sure why this query does not work

    Textboxes 4 and 5 may contain numbers, but to Excel they are still strings. You may need to also verify that they contain a number to avoid errors, but the calculation would probably work better if you use Clng(Textbox5.Value) and same logic for Textbox4. Just a quick guess since there is no sample workbook or broader code.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Contributor
    Join Date
    03-30-2020
    Location
    Gibraltar, Gibraltar
    MS-Off Ver
    365
    Posts
    150

    Re: Not sure why this query does not work

    Hi,

    Using that in mind I did a Len against itself so the answer would be a number and it worked fine. Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. SQL query that won't work in VBA
    By JapanDave in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-07-2017, 10:31 PM
  2. [SOLVED] Why won't this SQL SELECT query work?
    By mc84excel in forum Access Tables & Databases
    Replies: 3
    Last Post: 12-08-2014, 01:44 AM
  3. [SOLVED] Getting Inner Join to work in a VBA-based query to MS SQL
    By habang in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-24-2014, 12:44 PM
  4. MS Excel Query Won't Work
    By SOUT in forum Excel General
    Replies: 0
    Last Post: 06-07-2012, 04:08 PM
  5. web query on EXCEL does not work. Why?
    By jimf in forum Excel General
    Replies: 1
    Last Post: 01-04-2006, 01:10 AM
  6. web query doesn't work
    By Brian Allen in forum Excel General
    Replies: 0
    Last Post: 11-17-2005, 07:55 AM
  7. Combining Work Sheets/MS Query
    By Mark McWilliams in forum Excel General
    Replies: 1
    Last Post: 06-16-2005, 10:05 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1