Results 1 to 3 of 3
  1. #1
    jimmyac23 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    5

    Combo box value requirement for query row source

    I am working in MS Access 2007 and have a form with combo boxes whose row sources are pulled from a query. How do I make sure that these values are required?




    For example, I have other combo boxes whose row sources are from a table, and with those table values having a required property, a message appears every time I click my command button to insert a new record stating that the command box value must be entered. I want to replicate this result for the command boxes whose row sources are from a query, but do not know how to do so.


    I have tried several different methods:
    *Creating a validation rule in the property sheet, but I need to make sure that the the combo boxe's value cannot be null or cannot be an empty string aka "".
    *Using VBA to set the Validation Property, but I am still able to add the record and don't get a warning message.
    *Using VBA to create a MsgBox if the combo box is null when the command button is clicked, but this doesn't seem to be successful.


    Thank you and have a great weekend!
    Last edited by RuralGuy; 09-12-2014 at 09:28 AM. Reason: Removed URL link

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Please show some related code.

  3. #3
    jimmyac23 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2014
    Posts
    5
    Code:
    Option Compare Database
    
    
    Function SetValidation(stringtxt As String)
        Set ContactPosition.ValidationRule = stringtxt
    End Function
    
    
    
    
    
    
    Private Sub ContactType_AfterUpdate()
        ContactPosition.Requery
        ContactPosition.Value = ""
    End Sub
    
    
    Private Sub Region_AfterUpdate()
        Borough.Requery
        Borough.Value = ""
        Neighborhood.Value = ""
    End Sub
    
    
    Private Sub Borough_AfterUpdate()
        Neighborhood.Requery
        Neighborhood.Value = ""
    End Sub
    
    
    
    
    Private Sub SubmitCommand_Click()
        If IsNull(ContactPosition) Then
        MsgBox ("Test")
        End If
    End Sub

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

Similar Threads

  1. Replies: 1
    Last Post: 11-28-2013, 10:03 PM
  2. row source for a combo box
    By crowegreg in forum Forms
    Replies: 1
    Last Post: 02-05-2013, 05:18 PM
  3. Replies: 3
    Last Post: 12-11-2012, 09:12 AM
  4. Replies: 4
    Last Post: 05-04-2012, 02:03 AM
  5. Replies: 7
    Last Post: 06-30-2011, 12:20 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