Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Posts
    11

    Question Unanswered: Prevent duplicate selctions inside a subform

    I have a subform with in a form that allows the user to select additonal members for a comittee. The main form has a combo box in it, where they need to choose their Employee ID (goes into tbl 1), and the subform has additonal Employee ID combo box (goes into tbl 2). People sometimes select their own ID in the subform, and I'm trying to keep this from happening. I set up a VBScript on AfterUpdate with an If statement like this:

    Private Sub Alias_AfterUpdate()
    If (Me.EmployeeID) = (Forms)!(Form Name)(EmployeeID) Then
    MsgBox ("Comment.")
    End
    Cancel = True
    End If
    End Sub

    A message box will pop up if the Employee ID is the same as in the main form, but it also pops up if the Employee ID is different. I aslo tried the If statement when it looks at the tables, but it does the same things. Both the form and subform are connected by a AutoNumber field called Request ID. Anyone know how to keep duplicate entries from happening within a subform?

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Create a flag on your employee table called something like IsVisible ... In yout subform's Form_Update event run a query to set that flag to false AND requery the combobox. You combobox should have a RowSource like: SELECT * FROM SomeTable WHERE (IsVisible=True);

Posting Permissions

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