Change the textbox visible to true via main form

Alvin85

Registered User.
Local time
Today, 20:34
Joined
Jul 7, 2018
Messages
17
Hi,

I have 2 forms namely form1,form2.
I have an label named lblerror, a textbox named txtsearch and a button named btn_next in form1. lblerror default visible is false
I have 2 textbox name txt1 and txt2. and a button named btn return. Both txt1 and txt2 default visible is false.

If user key 2 in the form1 txtsearch and click on the btn_next, the program will bring me to form2 with the txt2.visible = true while txt1.visible=false.
If user key 1 in the form1 research and click on the btn_next, the program will bring me to form2 with the txt1.visible = true while txt2.visible=false.

If user key other then 1 or 2, program will stay in form1 and lblerror.visible = true.

May i ask how do i do the coding for the part that had been bolded?
 
If user key other then 1 or 2, program will stay in form1 and lblerror.visible = true.
If the user only has 2 choices I would be inclined to use an option group, a combobox, or a listbox to limit the choices.

To open the different forms you could use an If \ then statement or a select case statement.

for arguments sake, suppose you have a combobox (cboChoices) that has a value of 1 or 2.

you could have code like

Code:
Select case me.cboChoices

Case 1

Docmd.OpenForm "Form2"

forms("Form2").txt1.visible = true
forms("Form2").txt2.visible = false

Case 2

Docmd.OpenForm "Form2"

forms("Form2").txt2.visible = true
forms("Form2").txt1.visible = false

End Select
 
Thank you for the idea. :)
 

Users who are viewing this thread

Back
Top Bottom