+ Reply to Thread
Results 1 to 4 of 4

Compile Error

  1. #1
    Forum Contributor
    Join Date
    04-02-2013
    Location
    Hollywood, Fl
    MS-Off Ver
    Excel 2010
    Posts
    110

    Compile Error

    I'm trying to add a validation on a box within a userform that I am working on. I want to make sure that if the user selects the value Direct within a combo box within the userform, they will be unable to leave the TxtAmt box empty. They will have to enter a numeric value within the box if Direct is selected. I thought if I added
    Please Login or Register  to view this content.
    Users would no longer be able to leave the amount box blank. Unfortunately, I cannot even get to the testing phase, because I encounter a Compile Error: Expected expression, and the <> operator is highlighted. I also tried to write it using
    Please Login or Register  to view this content.
    instead of
    Please Login or Register  to view this content.
    But that didn't work either. Can anyone tell me what I am doing wrong? I added the if statement at the end of the sub-query. Here's the entire sub-query:
    Please Login or Register  to view this content.
    I appreciate any and all help. Thanks!

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Compile Error

    <> is a comparison operator; = is both a comparison operator and an assignment operator, depending on context, and assignment is what you need here:

    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Compile Error

    Why are you triggering it as this event?

    Please Login or Register  to view this content.
    This line is problematic (and incorrect)

    Please Login or Register  to view this content.
    This isn't really doing much of anything. All you are doing is changing txtAmt.Text. Maybe this:
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    04-02-2013
    Location
    Hollywood, Fl
    MS-Off Ver
    Excel 2010
    Posts
    110

    Re: Compile Error

    Quote Originally Posted by stnkynts View Post
    Why are you triggering it as this event?

    Please Login or Register  to view this content.
    This line is problematic (and incorrect)

    Please Login or Register  to view this content.
    This isn't really doing much of anything. All you are doing is changing txtAmt.Text. Maybe this:
    Please Login or Register  to view this content.
    Thanks Stnkynts, that last example worked.

+ 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. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  2. [SOLVED] Compile Error in Hidden Module and Compile Error: Can't find project or library
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-10-2013, 07:03 PM
  3. Syntax Error and Compile Error: Expected Line Number or Label...
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2011, 09:59 AM
  4. compile error: compile error expected
    By odeno in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2008, 04:30 PM
  5. VBAProject name compile error, not defined at compile time
    By Matthew Dodds in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2005, 03:20 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