Results 1 to 8 of 8
  1. #1
    vugar is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    53

    Field required in Form


    Hi everyone,

    I have a form Incoming there this required field: ECID, ItemID,StatisID and ShelfID.

    Can I set required rule and msg box to this field in form?

    thank you

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    You can create rules at the table level to require fields (Validation Rule and Validation Text properties), but I find this confusing. I prefer to use VBA to manage constraints. This way, I can look at the VBA to understand most all of the rules and I do not have hidden rules in the properties of tables.

  3. #3
    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
    I agree with ItsMe, about being able to go into the code module and have everything right there! It's one of the reasons why I also prefer VBA code over Embedded Macros.

    There are a number of ways to approach this, the clearest for newbies would probably be something like this:
    Code:
    Private Sub Form_BeforeUpdate(Cancel As Integer)
    
     If Nz(Me.ECID,"") = "" Then
       MsgBox "ECID Must Not Be Left Blank!"
       Cancel = True
       ECID.SetFocus
       Exit Sub
     End If
     
    If Nz(Me.ItemID,"") = "" Then
       MsgBox "ItemID Must Not Be Left Blank!"
       Cancel = True
       ItemID.SetFocus
       Exit Sub
     End If
    
    If Nz(Me.StatisID,"") = "" Then
       MsgBox "StatisID Must Not Be Left Blank!"
       Cancel = True
       StatisID.SetFocus
       Exit Sub
     End If
     
    If Nz(Me.ShelfID,"") = "" Then
       MsgBox "ShelfID Must Not Be Left Blank!"
       Cancel = True
       ShelfID.SetFocus
       Exit Sub
     End If
    
    End Sub

    Linq ;0)>

  4. #4
    vugar is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    53
    Thank you for reply.
    Last edited by vugar; 10-21-2015 at 02:19 AM.

  5. #5
    vugar is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    53
    I have two main tables of incoming and outgoing.

    I have crate stock Query with following fields

    ItemID (Group By) , StatusID (Group By), Quantity (Sum)

    And In Outgoing Form
    ItemID, StatusID, ReceivedQuantity

    I don't want the user to give a qty more than the qty available in the Stock.

    I write validation rule in Outgoing Form-ReceivedQuantity: <=Nz(DLookUp("[SumOfQuantity]","[TotalInStock]"," ItemID = " & [ItemID] & "And [Status ID] = " & [Status ID]),0)


    As I understanding it would better if I write it on VBA.

    My problem that I new in VBA. So I can't do it.

  6. #6
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933

  7. #7
    vugar is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Apr 2014
    Posts
    53
    Can you give your idea please, what should i use here, thanks in advanced.

  8. #8
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    The link didn't work Ajax, not sure if removed or mistake. Just FYI

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

Similar Threads

  1. Replies: 4
    Last Post: 06-29-2015, 01:56 PM
  2. Replies: 10
    Last Post: 06-18-2015, 11:52 AM
  3. Replies: 4
    Last Post: 11-04-2014, 07:35 PM
  4. Replies: 1
    Last Post: 12-07-2012, 02:14 AM
  5. Required Field Help
    By brandonb in forum Access
    Replies: 4
    Last Post: 11-13-2009, 11:18 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