VBA code if value > 0 MsgBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Karen Flores
    New Member
    • Apr 2011
    • 1

    VBA code if value > 0 MsgBox

    Hi all,

    This is a first question:). I'm from PR.
    Im triyng developing VBA en Access.
    I would like a code that when the value > o appear a Msg Box. I have create a form, my problem is that i dont know what expression i can use, for appear msg box in the form.

    Please let me know what else we can do to make this work again.

    This is my attemp:
    We have: Private Sub Total_de_neumát icos_generados_ –_Total_de_neum áticos_recibido s

    I wolud like know if the result is >0 appear a msg box.

    Private Sub Total_de_neumát icos_generados_ –_Total_de_neum áticos_recibido s_AfterUpdate()

    If [Total_de_neumát icos_generados_ –_Total_de_neum áticos_recibido s] > 0 Then
    MsgBox "Please enter number > 0"

    End If
    End Sub


    Thanks againg for your help.
    Thanks so much!



    K
  • Mihail
    Contributor
    • Apr 2011
    • 759

    #2
    My practice:

    Declare 2 PUBLIC variables (Module level)

    Code:
    PUBLIC Msg as vbMsgBoxResults
    PUBLIC Txt as String
    Use:

    Code:
    Private Sub MyProc
         Txt = "The information to be displayed"
         Msg = MsgBox(Txt,vbYesNo,,,)
         If Msg = vbYes then
            'Do something
         Else
            'Do otherthing
         End IF
    End Sub
    The second question:

    Code:
    If N1 - N2 < 0 then
         Txt = "Please enter a number ...."
         Msg = MsgBox(Txt)
    End IF
    And... Why you test AFTER update ? I think you must test BEFORE update.

    Note that MsgBox control has more options (see HELP for this control)

    Good luck !

    Comment

    Working...