Results 1 to 3 of 3
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    114
    Thanks
    0
    Thanked 0 Times in 0 Posts

    forbid control in the subform (Access 2000)

    May i receive an advice how can i forbid selecting a product in the subform,if the customer has not selected an emplolyee in the
    main form ?
    My last control in the main form is called Employeeid.In the after date event i have the following code:
    DoCmd.RunCommand acCmdSaveRecord
    Me![FOfferdetails].SetFocus

    After that the user selects a product from the subform from the control called ProductID. This control is a combo box ,
    the user selects a product from this combo box and issues an order.
    However the user could select a product without selecting at first an employee in the main form, and i want to forbid
    this possibility.
    My idea of the code consist in the following code placed in the AfterUpdate event of the control ProductID:


    If Parent![employeeid] = " Then
    MsgBox "Please select an employee"
    Exit sub

    This lines seem to be of no use since i am allowed to select a products and nothing happens, no error,but
    i am not forbidden to continue if i have not selected an employee.
    How can i reformulate my condition?

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: forbid control in the subform (Access 2000)

    To stop users selecting a product set its enabled property to NO.
    Then put code in the afterupdate event for the employee in the main form that sets the enabled property back to Yes if the employee field is not null.
    You would also need code to reset the enabled property to No whenever you go to a new record, and if you can browse through exsting records to set its value appropriately as you move through records.

    Another option, closer to what you tried would be to use the beforeupdate event for productid
    If isNull(me!Parent![employeeid]) Then
    MsgBox "Please select an employee "
    cancel = true
    end if
    Actually, you might need to change the first line to:
    If isNull(me!Parent![employeeid]) and not isnull(me!Productid]) Then
    otherwise you might not be able to get out of the productID field to go back to put the employee in.
    Regards
    John



  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: forbid control in the subform (Access 2000)

    You could set .Enabled=false or .Locked=true for that ProductID control. Or, if you didn't want the user to do anything in the subform until the employee ID was entered, you could set the same properties for the subform control.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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