none
If one field filled in do not allow to fill in another one RRS feed

  • Question

  • Good Afternoon,

    I have a form in Access 2010 that I am trying to do an "Either or".

    Let me elaborate for better understanding what I mean, I have two text boxes one labeled "email" the other labeled "Phone call". If someone enters "1" in the "email" box, I would like to block the next text box in order not to capture anything in that box. Or... if we "TAB" over (skip or leave blank) the "email" box I would like to be able to add the number in the "Phone Call" box. How would be the easiest way to accomplish this?

    Thank you, 

    Thursday, August 11, 2016 10:40 PM

Answers

  • Hi Mexgee,

    you can use the Textbox_change event of Textbox to do this.

    then in the event you can disabled the another textbox.

    there is also a many events are there if you don't want to use Textbox_Change Event. you can choose the one which you think it's the best suitable for your requirement.

    Following is the Form design and Code.

    Here it works when you edit the Textbox. because I think it is a better approach then just Disable the another textbox on "Tab".

    Private Sub Text0_Change()
    Me.Text2.Enabled = False
    End Sub
    
    Private Sub Text2_Change()
    Me.Text0.Enabled = False
    End Sub

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, August 12, 2016 12:22 AM
    Moderator
  • One way to do this is to use an option frame with 2 options: email or phone. Then use the After_Update event to make the specific text box enabled or not.

    But there may come a time when you would actually want to let a user enter in both boxes. Sounds like you need to re-think your design.


    Bill Mosca
    www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Friday, August 12, 2016 1:55 PM

All replies

  • Hi Mexgee,

    you can use the Textbox_change event of Textbox to do this.

    then in the event you can disabled the another textbox.

    there is also a many events are there if you don't want to use Textbox_Change Event. you can choose the one which you think it's the best suitable for your requirement.

    Following is the Form design and Code.

    Here it works when you edit the Textbox. because I think it is a better approach then just Disable the another textbox on "Tab".

    Private Sub Text0_Change()
    Me.Text2.Enabled = False
    End Sub
    
    Private Sub Text2_Change()
    Me.Text0.Enabled = False
    End Sub

    Regards

    Deepak


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, August 12, 2016 12:22 AM
    Moderator
  • One way to do this is to use an option frame with 2 options: email or phone. Then use the After_Update event to make the specific text box enabled or not.

    But there may come a time when you would actually want to let a user enter in both boxes. Sounds like you need to re-think your design.


    Bill Mosca
    www.thatlldoit.com
    http://tech.groups.yahoo.com/group/MS_Access_Professionals

    Friday, August 12, 2016 1:55 PM