+ Reply to Thread
Results 1 to 8 of 8

Message box not showing

  1. #1
    Registered User
    Join Date
    02-04-2016
    Location
    Manila
    MS-Off Ver
    2007
    Posts
    4

    Message box not showing

    Hi Guys,

    Please help. I have this code for my search button in formcontrol. The search function is working everytime I enter an exact value but when I enter a value that is not in the list, its not prompting the message box that says "No record".

    Private Sub CommandButton1_Click()

    For Each c In Sheet11.Range("C:C").Cells
    If c.Value <> "" Then
    If TextBox9.Value = c.Value Then
    TextBox1date.Value = c.Offset(0, -1).Value
    TextBox2spr.Value = c.Offset(0, 5).Value
    TextBox3cust.Value = c.Offset(0, 1).Value
    TextBox4proj.Value = c.Offset(0, 2).Value
    TextBox5cont.Value = c.Offset(0, 4).Value
    TextBox6datesub.Value = c.Offset(0, 8).Value
    TextBox7lostval.Value = c.Offset(0, 10).Value
    TextBox8remark.Value = c.Offset(0, 11).Value
    TextBox10.Value = c.Offset(0, 3).Value
    TextBox11.Value = c.Offset(0, 6).Value
    TextBox12.Value = c.Offset(0, 7).Value
    TextBox13.Value = c.Offset(0, 9).Value
    TextBox14.Value = c.Offset(0, 12).Value

    ElseIf TextBox9.Value <> c.Value Then
    MsgBox "No record"

    Else
    End If
    Else
    Exit Sub
    End If
    Next
    End Sub

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Message box not showing

    Hi and welcome to the forum. Unfortunately your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-04-2016
    Location
    Manila
    MS-Off Ver
    2007
    Posts
    4

    Re: Message box not showing

    oops, Im sorry. Here you go:

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Message box not showing

    Hi,

    I can't see anything in the syntax that wouldn't work as you expect. In passing I don't see the need for both
    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    since these are mutually exclusive but I don't think that will cause the message box not to pop up.

    Have you done the obvious debugging and stepped through the code to examine the value of TextBox9 and c?

    Neither is it clear what you mean by 'enter a value that is not in the list'. What Value? alpha or numeric? What List?

    You'd be better uploading the workbook and indicating what you enter when you click the button so that we can see the request in context.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Message box not showing

    Your code will exit the procedure if any cell has no value, so I guess you have blank cell before the cells with value.

  6. #6
    Registered User
    Join Date
    02-04-2016
    Location
    Manila
    MS-Off Ver
    2007
    Posts
    4

    Re: Message box not showing

    Hi Thank you for the prompt reply.

    Here is my excel attachment

    2.SPR register2.xls

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Message box not showing

    Change to
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-04-2016
    Location
    Manila
    MS-Off Ver
    2007
    Posts
    4

    Re: Message box not showing

    Thanks so much for the help jindon and Richard! it 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. Nested If showing error message
    By Weaselwithagun in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-08-2015, 01:06 PM
  2. Internet Explorer showing strange message
    By Tony Valko in forum The Water Cooler
    Replies: 0
    Last Post: 06-01-2015, 04:36 PM
  3. status bar not showing the message
    By bezbid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-03-2015, 12:59 AM
  4. [SOLVED] Showing total value in column on message box
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-10-2014, 04:46 PM
  5. Showing message
    By Maya9 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-05-2011, 12:03 PM
  6. Showing/Displaying Message to User
    By DJ89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2006, 09:37 AM
  7. [SOLVED] How to print when an error message keeps showing?
    By clueless in forum Excel General
    Replies: 1
    Last Post: 01-30-2006, 01:40 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