Results 1 to 2 of 2
  1. #1
    steve87bg is offline Novice
    Windows 8 Access 2013
    Join Date
    Jan 2013
    Posts
    1

    Question Display custom error if field is null or zero

    I have a code,


    Code:
    Private Sub Dodaj_Click()
    
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.SetWarnings False
    DoCmd.OpenQuery ("QDodaj")
    DoCmd.SetWarnings True
    
    On Error GoTo Err_Dodaj_Click
    
    
    DoCmd.GoToRecord , , acNewRec
    Me.DatumKnjizenja.SetFocus
    Me.DatumKnjizenja = ""
    
    Me.Kom = 0
    Me.Gr = 0
    
    Me.Dodaj.Enabled = False
    
    Exit_Dodaj_Click:
    Exit Sub
    
    Err_Dodaj_Click:
    MsgBox Err.Description
    Resume Exit_Dodaj_Click
    
    End Sub
    I whant if me.kom or me.Gr is null or zero to display custom error

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why does the code set Kom and Gr to 0?

    Use MsgBox.

    If Nz(Me.Kom,0) =0 Or Nz(Me.Gr) = 0 Then
    MsgBox "Kom or Gr or both are empty or equal to zero."
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Snytax Error - Counting a Not Null field
    By Huddle in forum Access
    Replies: 2
    Last Post: 06-29-2012, 12:30 PM
  2. subform primary key null value want custom msg
    By raton in forum Programming
    Replies: 1
    Last Post: 03-24-2012, 11:35 AM
  3. Replies: 5
    Last Post: 10-18-2011, 11:37 AM
  4. Query search wont display null fields
    By Coffee in forum Queries
    Replies: 2
    Last Post: 08-08-2011, 09:00 AM
  5. make query fields not display if null data
    By rivereridanus in forum Queries
    Replies: 1
    Last Post: 07-05-2011, 08:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums