?
Solved

How to put a messagebox in vb

Posted on 2008-10-09
12
Medium Priority
?
160 Views
Last Modified: 2012-05-05
i need to put a message box on the for the error 3021

how to do that?


Public Sub CheckForNullSearch()
On Error GoTo Err_CheckForNullSearch
    
    'Checks general search form for any nulls
    'Dirty = False
    
    If IsNull(Me.Combo_Year) Or Me.Combo_Year = "0" Or Me.Combo_Year = "" Then Me.Combo_Year = "Year"
    If IsNull(Me.Combo_TempPromoID) Or Me.Combo_TempPromoID = "" Then Me.Combo_TempPromoID = "0"
    If IsNull(Me.Combo_EnteredBy) Or Me.Combo_EnteredBy = "0" Or Me.Combo_EnteredBy = "" Then Me.Combo_EnteredBy = "Log on"
    If IsNull(Me.Combo_PromoPeriod) Or Me.Combo_PromoPeriod = "0" Or Me.Combo_PromoPeriod = "" Then Me.Combo_PromoPeriod = "Period"
    If IsNull(Me.Combo_Location) Or Me.Combo_Location = "" Or Me.Combo_Location = "" Then Me.Combo_Location = "Location"
    If IsNull(Me.Combo_CategoryMan) Or Me.Combo_CategoryMan = "0" Or Me.Combo_CategoryMan = "" Then Me.Combo_CategoryMan = "Category Manager"
    If IsNull(Me.Combo_CatID) Or Me.Combo_CatID = "" Then Me.Combo_CatID = "0"
    If IsNull(Me.Combo_StartDate) Or Me.Combo_StartDate = "" Or Me.Combo_StartDate = "0" Then Me.Combo_StartDate = "Start Date"
    If IsNull(Me.Combo_Status) Or Me.Combo_Status = "" Or Me.Combo_Status = "0" Then Me.Combo_Status = "Status"
    If IsNull(Me.Combo_article) Or Me.Combo_article = "" Or Me.Combo_article = "0" Then Me.Combo_article = "0"
    
    'Dirty = False
    
Exit_CheckForNullSearch:
    Exit Sub
 
Err_CheckForNullSearch:
    
    'Entered an item not in the list
    If Err.Number = 2237 Then Resume Next
    
    'If a Null value after the dirty=false then error will occur
    If Err.Number = 3058 Then Resume Next
                        
    'No current record
    If Err.Number = 3021 Then Resume Next
                        
    ApplicationError Err.Number, Err.Description, "T_F900_GeneralSearch\CheckForNullSearch"
    Resume Exit_CheckForNullSearch
    
End Sub

Open in new window

0
Comment
Question by:jaisonshereen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 

Author Comment

by:jaisonshereen
ID: 22676904
this is not working
If Err.Number = 3021 Then
    Err.Clear
    MsgBox ("test")
    Resume Next
    Else
    ApplicationError Err.Number, Err.Description, "T_F900_GeneralSearch\CheckForNullSearch"
    Resume Exit_CheckForNullSearch
    End If
    End Sub

Open in new window

0
 
LVL 10

Assisted Solution

by:c0ldfyr3
c0ldfyr3 earned 800 total points
ID: 22677059
Change

MsgBox ("test")


To

Call MsgBox ("test")

0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 1200 total points
ID: 22677227
change your code, like this:


AW
Err_CheckForNullSearch:
    Dim ans as Integer
    ans = -1
    'Entered an item not in the list
    If Err.Number = 2237 Then 
      Err.Clear
      ans = MsgBox("'Entered an item not in the list" & vbCrlF & "Do you wish to continue?", vbYesNo)
      If ans = vbYes then
          Resume Next
      End If
    End If
    
    'If a Null value after the dirty=false then error will occur
    If Err.Number = 3058 Then 
      Err.Clear
      ans = MsgBox("Null value after the dirty=false " & vbCrlF & "Do you wish to continue?", vbYesNo)
      If ans = vbYes then
          Resume Next
      End If
    End If
                        
    'No current record
    If Err.Number = 3021 Then
      Err.Clear  
      ans = MsgBox("No current record" & vbCrlF & "Do you wish to continue?", vbYesNo)
      If ans = vbYes then
          Resume Next
      End If
    End If
 
    If ans = -1 then                   
         ApplicationError Err.Number, Err.Description, "T_F900_GeneralSearch\CheckForNullSearch"
    End If
    Resume Exit_CheckForNullSearch

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:jaisonshereen
ID: 22677300
nope its not works..3021 error message box comming instead
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 22677351
which suggested answer does not work?

AW
0
 

Author Comment

by:jaisonshereen
ID: 22677373
nothing works !
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 22677595
try this, and tell me what the Message Box shows:
Err_CheckForNullSearch:
    Dim ans as Integer
    ans = -1
    'Entered an item not in the list
    If Err.Number = 2237 Then 
      Err.Clear
      ans = MsgBox("'Entered an item not in the list" & vbCrlF & "Do you wish to continue?", vbYesNo)
      If ans = vbYes then
          Resume Next
      End If
    End If
    
    'If a Null value after the dirty=false then error will occur
    If Err.Number = 3058 Then 
      Err.Clear
      ans = MsgBox("Null value after the dirty=false " & vbCrlF & "Do you wish to continue?", vbYesNo)
      If ans = vbYes then
          Resume Next
      End If
    End If
                        
    'No current record
    If Err.Number = 3021 Then
      Err.Clear  
      ans = MsgBox("No current record" & vbCrlF & "Do you wish to continue?", vbYesNo)
      If ans = vbYes then
          Resume Next
      End If
    End If
    MsgBox "Err.Number = " & err.Number, vbOkOnly
    If ans = -1 then                   
         ApplicationError Err.Number, Err.Description, "T_F900_GeneralSearch\CheckForNullSearch"
    End If
    Resume Exit_CheckForNullSearch

Open in new window

0
 

Author Comment

by:jaisonshereen
ID: 22677645
no hope

still the same 3021 error msgbox :-(
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 22678288
Ok, I know what is going on.  It seems that there are a broad range of Run-Time errors that are NOT 'Trappable' - that is, when they occur, they do NOT trigger the On Error Goto .... error handler mechanism.

If you open the VB6 IDE, and click on Help, then select Index, and enter "Trapping Errors", you will get the 'official' list of Trappable run-time errors.  Non of the errors you are attemting to handle are listed as Trappable Run-Time errors.

What routine is calling your CheckForNullSearch procedure?  The error is probably occuring there.

AW
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 22678436
In addition, there is NOTHING in your procedure CheckForNullSearch which is in ant way related to the 3021 - No Crrent Record condition.  The code in your procedure does not make use of a recordset, or attempting to access data from a recordset.  Thast should be an additional indication that the error you are getting is not being triggered in the procedure where you seem to think it is occurring.

AW
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 22680658
Glad to be of assistance.  How did you resolve this issue?

AW
0
 

Author Comment

by:jaisonshereen
ID: 22680729
i gone for debugging  by cntr+break

where i see n the cursor position i put the message box with the case:3021

still

err.clear  resolved the issue!

Thanks all support !
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question