Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2003

    Unanswered: required data in combo box


    I have a form with 20 combo boxes on it for data entry. There are times when my people need to move to a new record without completing the first record, so I don't have "REQUIRED" set for all combos. However, I'd like to somehow tell Access (I'm assuming via code) that:

    Combo Box "station" must be filled in if Combo Box "dept" has "upholstery" as the selection. Can someone help?

    Thank you much,

  2. #2
    Join Date
    Nov 2003

    Combo Boxes


    I would suggest that your form has too many combo boxes on it. When you have a lot of records in the database your users will find the form opening very slowly. Its better to split the form up into smaller coherent chunks.

    In answer to your question, to valdiate the data entered on a form you use the forms BeforeUpdate method. This allows you to check and undo a user entry before the data is saved. The code would look like:

    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Me("Dept").Value = "Upholstery" Then
    If Len(Me("Station")) = 0 Or IsNull(Me("Station")) Then
    Msgbox "You must enter a Station value",vbInformation,"Value Required"
    Cancel = True ' Stops the data from being updated
    End If
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts