Results 1 to 5 of 5
  1. #1
    ariansman is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    57

    required controlbox

    I have a table named kidsjobs. There is a field in this table named kharidar which is not a required field.


    A form has been made on this table. It has a control box named kharidar, bound to the above mentioned field named kharidar. I want to design the form so that the user cannot close or move to next record, unless the controlbox kharidar in the form is not blank. i dont want to make the field in the table required. The names are actual. Please help me have the vba code or anything that works to get this task.
    thank you

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Use the forms BeforeUpdate event to check if kharidar is null. The event can be cancelled with Cancel = true if the validation fails at which point you may want to display a message box to advise the user.
    EDIT:
    Is this some kind of school home-work?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2019
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Perhaps something like:
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer) 
         If IsNull(Me.kharidar) Then
            MsgBox "Enter data for 'kharidar' ", , "DATA REQUIRED"
            Cancel = True
        End If
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    ariansman is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2013
    Posts
    57
    thank you. it worked

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    This just begs the question...'Why do you want a Field to be Required...but not be Required?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Examples of where .Value is required?
    By Micron in forum Access
    Replies: 5
    Last Post: 07-05-2022, 09:43 AM
  2. Replies: 3
    Last Post: 07-07-2020, 10:35 AM
  3. Valadation required
    By bopsgtir in forum Access
    Replies: 45
    Last Post: 01-08-2011, 11:25 AM
  4. Hello! Help required if possible please...
    By MarkGLyons in forum Access
    Replies: 21
    Last Post: 12-28-2010, 05:36 AM
  5. immediate help required
    By pdurgi in forum Access
    Replies: 1
    Last Post: 06-05-2009, 08:21 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