Results 1 to 2 of 2
  1. #1
    raton is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2012
    Posts
    22

    subform primary key null value want custom msg

    I have a form with a subform. a primary key(not auto number) field in the subform. if i insert a number in the primary key field. then i delete the number and want to close the main form by clcking x button without saving any record. then the msg "a primary key cannot contain a null value" then a msaccess standard msg. but what i want is My custom msg and not any standard msg

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Review this http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

    Try:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If IsNull(primary key field) Then
    Me.Undo
    End If
    End Sub

    Can put a message box in there but that might just be an annoyance for the user to have to click another button.
    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. Replies: 3
    Last Post: 10-11-2011, 01:43 PM
  2. Replies: 9
    Last Post: 07-14-2011, 07:20 AM
  3. index/primary cannot contain null value
    By BinHDreW in forum Access
    Replies: 1
    Last Post: 05-26-2011, 08:25 PM
  4. Replies: 1
    Last Post: 08-03-2010, 01:33 PM
  5. Replies: 6
    Last Post: 02-19-2010, 03:52 PM

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