If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Hide or show Control Button on Form in Access 97
I have several control buttons on a form. I would like the control buttons to be hidden unless there is specific text in a control. How can I make the Visible property of these control buttons be "Yes" depending on the text in a control on the form and "No" if the text is other than the desired text. Any assistance greatly appreciated.
|
#2
|
|||
|
|||
Hide or show Control Button on Form in Access 97
Pete,
You will need a couple of line of code in the textbox control's Before Update event: If Me.txtbox1 = "specific text" Me.cmdbutton1.Visible = True Else Me.cmdbutton1.Visible = False End If I would suggest you use the same code in the form's On Current event, so the button is made visible.invisible according to the value of the field in each record as you browse through... or you could put the code in a private sub in the form's module, and call it from the two events (so you don't have to repeat it twice). HTH, Nikos "Pete Sperling" wrote in message news I have several control buttons on a form. I would like the control buttons to be hidden unless there is specific text in a control. How can I make the Visible property of these control buttons be "Yes" depending on the text in a control on the form and "No" if the text is other than the desired text. Any assistance greatly appreciated. |
#3
|
|||
|
|||
Hide or show Control Button on Form in Access 97
Nikos,
A couple of other questions - The command buttons in question are contained in the Form Header of a Sub-Form. The control that contains the specific test is located in the Main Form's Detail area. How is this going to affect the way the code is written? How do I add addtional "cmdbutton2, 3, 4, etc"? Unfortunately I have no background in writing code. Thanks for your assistance. "Nikos Yannacopoulos" wrote: Pete, You will need a couple of line of code in the textbox control's Before Update event: If Me.txtbox1 = "specific text" Me.cmdbutton1.Visible = True Else Me.cmdbutton1.Visible = False End If I would suggest you use the same code in the form's On Current event, so the button is made visible.invisible according to the value of the field in each record as you browse through... or you could put the code in a private sub in the form's module, and call it from the two events (so you don't have to repeat it twice). HTH, Nikos "Pete Sperling" wrote in message news I have several control buttons on a form. I would like the control buttons to be hidden unless there is specific text in a control. How can I make the Visible property of these control buttons be "Yes" depending on the text in a control on the form and "No" if the text is other than the desired text. Any assistance greatly appreciated. |
#4
|
|||
|
|||
Hide or show Control Button on Form in Access 97
Pete,
To your first question, assuming the subform is called SubForm1, the references to the command buttons on it should change to: Me.SubForm1.Formcmdbutton1 etc, so the code would become: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False End If To do the same for multiple buttons, you could either repeat the line of code after the If / Else keywords, adding one for each button, like: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Me.SubForm1.cmdbutton2.Visible = True Me.SubForm1.cmdbutton3.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False Me.SubForm1.cmdbutton2.Visible = False Me.SubForm1.cmdbutton3.Visible = False End If For a big number of buttons you could employ a loop, but it's unlikely it's your case. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, A couple of other questions - The command buttons in question are contained in the Form Header of a Sub-Form. The control that contains the specific test is located in the Main Form's Detail area. How is this going to affect the way the code is written? How do I add addtional "cmdbutton2, 3, 4, etc"? Unfortunately I have no background in writing code. Thanks for your assistance. "Nikos Yannacopoulos" wrote: Pete, You will need a couple of line of code in the textbox control's Before Update event: If Me.txtbox1 = "specific text" Me.cmdbutton1.Visible = True Else Me.cmdbutton1.Visible = False End If I would suggest you use the same code in the form's On Current event, so the button is made visible.invisible according to the value of the field in each record as you browse through... or you could put the code in a private sub in the form's module, and call it from the two events (so you don't have to repeat it twice). HTH, Nikos "Pete Sperling" wrote in message news I have several control buttons on a form. I would like the control buttons to be hidden unless there is specific text in a control. How can I make the Visible property of these control buttons be "Yes" depending on the text in a control on the form and "No" if the text is other than the desired text. Any assistance greatly appreciated. |
#5
|
|||
|
|||
Hide or show Control Button on Form in Access 97
Nikos,
I get - Compile error: Expected: Then or GoTo when I entered the following: Private Sub Form_Current() If Me.Combo3 = "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If End Sub What do I need to do to fix? Where/how would I add a different text for Combo3 above in order to change the visible property of Command8, Command9, etc.. Thanks for your assistance. Pete "Nikos Yannacopoulos" wrote: Pete, To your first question, assuming the subform is called SubForm1, the references to the command buttons on it should change to: Me.SubForm1.Formcmdbutton1 etc, so the code would become: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False End If To do the same for multiple buttons, you could either repeat the line of code after the If / Else keywords, adding one for each button, like: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Me.SubForm1.cmdbutton2.Visible = True Me.SubForm1.cmdbutton3.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False Me.SubForm1.cmdbutton2.Visible = False Me.SubForm1.cmdbutton3.Visible = False End If For a big number of buttons you could employ a loop, but it's unlikely it's your case. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, A couple of other questions - The command buttons in question are contained in the Form Header of a Sub-Form. The control that contains the specific test is located in the Main Form's Detail area. How is this going to affect the way the code is written? How do I add addtional "cmdbutton2, 3, 4, etc"? Unfortunately I have no background in writing code. Thanks for your assistance. "Nikos Yannacopoulos" wrote: Pete, You will need a couple of line of code in the textbox control's Before Update event: If Me.txtbox1 = "specific text" Me.cmdbutton1.Visible = True Else Me.cmdbutton1.Visible = False End If I would suggest you use the same code in the form's On Current event, so the button is made visible.invisible according to the value of the field in each record as you browse through... or you could put the code in a private sub in the form's module, and call it from the two events (so you don't have to repeat it twice). HTH, Nikos "Pete Sperling" wrote in message news I have several control buttons on a form. I would like the control buttons to be hidden unless there is specific text in a control. How can I make the Visible property of these control buttons be "Yes" depending on the text in a control on the form and "No" if the text is other than the desired text. Any assistance greatly appreciated. |
#6
|
|||
|
|||
Hide or show Control Button on Form in Access 97
Pete,
To begin with, apologies for the incomplete code! I missed out the Then: If Me.Combo3 = "TRID-TBD_REV_9.0G" Then etc. Now on to your new question: the code sample I rpovided yesterday for controlling the visibility of multiple buttons assumed they were all subject to the same "specific text" in the combo; if, as I understand now, it's a different text for each, then your code would have to have a separate If/Then/Else structure for each, like: If Me.Combo3 = "TRID-TBD_REV_9.0G" Then Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If If Me.Combo3 = "specific text B" Then Me.Equipment_F.Command8.Visible = True Else Me.Equipment_F.Command8.Visible = False End If If Me.Combo3 = "specific text C" Then Me.Equipment_F.Command9.Visible = True Else Me.Equipment_F.Command9.Visible = False End If 'etc End Sub As I understand, you only want to have one button visible in each case; under the circumstances, a different approach, which I personally find neater, would be to make them all invisible, and then selectively make just one visible, rather than executing a series if If/Then/Else checks, like: Me.Equipment_F.Command7.Visible = False Me.Equipment_F.Command8.Visible = False Me.Equipment_F.Command9.Visible = False 'etc for additional buttons Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Visible = True Case "specific text B" Me.Equipment_F.Command8.Visible = True Case "specific text C" Me.Equipment_F.Command9.Visible = True 'etc for additional buttons End Select End Sub If you want to take this a step further and make your form look more "professional", you could use a single command button, and change its caption and what it does through code, based on the selected value in combo3. To do this, assuming you are only using one button called Command7, your button would always be visible, and the code behind the combo event and the form's current event would be something like: Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Caption = "Do action A..." Case "specific text B" Me.Equipment_F.Command7.Caption = "Do action B..." Case "specific text C" Me.Equipment_F.Command7.Caption = "Do action C..." 'etc for additional cases End Select End Sub Then, the code behind the command button itself would be something like: Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" 'code for action A Case "specific text B" 'code for action B Case "specific text C" 'code for action C 'etc for additional cases End Select End Sub where you could include the actual code in the Select Case structure, or you could just call separate subs that contain the code pertaining to each selection. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, I get - Compile error: Expected: Then or GoTo when I entered the following: Private Sub Form_Current() If Me.Combo3 = "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If End Sub What do I need to do to fix? Where/how would I add a different text for Combo3 above in order to change the visible property of Command8, Command9, etc.. Thanks for your assistance. Pete "Nikos Yannacopoulos" wrote: Pete, To your first question, assuming the subform is called SubForm1, the references to the command buttons on it should change to: Me.SubForm1.Formcmdbutton1 etc, so the code would become: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False End If To do the same for multiple buttons, you could either repeat the line of code after the If / Else keywords, adding one for each button, like: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Me.SubForm1.cmdbutton2.Visible = True Me.SubForm1.cmdbutton3.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False Me.SubForm1.cmdbutton2.Visible = False Me.SubForm1.cmdbutton3.Visible = False End If For a big number of buttons you could employ a loop, but it's unlikely it's your case. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, A couple of other questions - The command buttons in question are contained in the Form Header of a Sub-Form. The control that contains the specific test is located in the Main Form's Detail area. How is this going to affect the way the code is written? How do I add addtional "cmdbutton2, 3, 4, etc"? Unfortunately I have no background in writing code. Thanks for your assistance. "Nikos Yannacopoulos" wrote: Pete, You will need a couple of line of code in the textbox control's Before Update event: If Me.txtbox1 = "specific text" Me.cmdbutton1.Visible = True Else Me.cmdbutton1.Visible = False End If I would suggest you use the same code in the form's On Current event, so the button is made visible.invisible according to the value of the field in each record as you browse through... or you could put the code in a private sub in the form's module, and call it from the two events (so you don't have to repeat it twice). HTH, Nikos "Pete Sperling" wrote in message news I have several control buttons on a form. I would like the control buttons to be hidden unless there is specific text in a control. How can I make the Visible property of these control buttons be "Yes" depending on the text in a control on the form and "No" if the text is other than the desired text. Any assistance greatly appreciated. |
#7
|
|||
|
|||
Hide or show Control Button on Form in Access 97
Nikos,
I corrected the code to read as follows: Private Sub Combo3_BeforeUpdate(Cancel As Integer) If Me.Combo3 = "TRID-TBD REV 9.0G" Then Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If End Sub Command Button 7 does not disappear when Combo3 contains something other than TRID-TBD REV 9.0G. In case I didn't previously mention: Combo3 is in the Detail area of the Main Form and Command Button 7 is located in the Form Header of the Sub-Form. Should this make any difference in the code? Am I correct in using the BeforeUpdate event in the Main Form? Should I be using Underscore "_" between characters that have spaces or just put a space, i.e. Equipment F is the name of the sub-form but I am using Equipment_F in the code? Again, thanks for any assistance. Pete I'm sure that once I can get one of the Command Buttons to appear and disappear I should have no problem adding the code for other Command Buttons. "Nikos Yannacopoulos" wrote: Pete, To begin with, apologies for the incomplete code! I missed out the Then: If Me.Combo3 = "TRID-TBD_REV_9.0G" Then etc. Now on to your new question: the code sample I rpovided yesterday for controlling the visibility of multiple buttons assumed they were all subject to the same "specific text" in the combo; if, as I understand now, it's a different text for each, then your code would have to have a separate If/Then/Else structure for each, like: If Me.Combo3 = "TRID-TBD_REV_9.0G" Then Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If If Me.Combo3 = "specific text B" Then Me.Equipment_F.Command8.Visible = True Else Me.Equipment_F.Command8.Visible = False End If If Me.Combo3 = "specific text C" Then Me.Equipment_F.Command9.Visible = True Else Me.Equipment_F.Command9.Visible = False End If 'etc End Sub As I understand, you only want to have one button visible in each case; under the circumstances, a different approach, which I personally find neater, would be to make them all invisible, and then selectively make just one visible, rather than executing a series if If/Then/Else checks, like: Me.Equipment_F.Command7.Visible = False Me.Equipment_F.Command8.Visible = False Me.Equipment_F.Command9.Visible = False 'etc for additional buttons Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Visible = True Case "specific text B" Me.Equipment_F.Command8.Visible = True Case "specific text C" Me.Equipment_F.Command9.Visible = True 'etc for additional buttons End Select End Sub If you want to take this a step further and make your form look more "professional", you could use a single command button, and change its caption and what it does through code, based on the selected value in combo3. To do this, assuming you are only using one button called Command7, your button would always be visible, and the code behind the combo event and the form's current event would be something like: Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Caption = "Do action A..." Case "specific text B" Me.Equipment_F.Command7.Caption = "Do action B..." Case "specific text C" Me.Equipment_F.Command7.Caption = "Do action C..." 'etc for additional cases End Select End Sub Then, the code behind the command button itself would be something like: Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" 'code for action A Case "specific text B" 'code for action B Case "specific text C" 'code for action C 'etc for additional cases End Select End Sub where you could include the actual code in the Select Case structure, or you could just call separate subs that contain the code pertaining to each selection. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, I get - Compile error: Expected: Then or GoTo when I entered the following: Private Sub Form_Current() If Me.Combo3 = "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If End Sub What do I need to do to fix? Where/how would I add a different text for Combo3 above in order to change the visible property of Command8, Command9, etc.. Thanks for your assistance. Pete "Nikos Yannacopoulos" wrote: Pete, To your first question, assuming the subform is called SubForm1, the references to the command buttons on it should change to: Me.SubForm1.Formcmdbutton1 etc, so the code would become: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False End If To do the same for multiple buttons, you could either repeat the line of code after the If / Else keywords, adding one for each button, like: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Me.SubForm1.cmdbutton2.Visible = True Me.SubForm1.cmdbutton3.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False Me.SubForm1.cmdbutton2.Visible = False Me.SubForm1.cmdbutton3.Visible = False End If For a big number of buttons you could employ a loop, but it's unlikely it's your case. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, A couple of other questions - The command buttons in question are contained in the Form Header of a Sub-Form. The control that contains the specific test is located in the Main Form's Detail area. How is this going to affect the way the code is written? How do I add addtional "cmdbutton2, 3, 4, etc"? Unfortunately I have no background in writing code. Thanks for your assistance. "Nikos Yannacopoulos" wrote: Pete, You will need a couple of line of code in the textbox control's Before Update event: If Me.txtbox1 = "specific text" Me.cmdbutton1.Visible = True Else Me.cmdbutton1.Visible = False End If I would suggest you use the same code in the form's On Current event, so the button is made visible.invisible according to the value of the field in each record as you browse through... or you could put the code in a private sub in the form's module, and call it from the two events (so you don't have to repeat it twice). HTH, Nikos "Pete Sperling" wrote in message news I have several control buttons on a form. I would like the control buttons to be hidden unless there is specific text in a control. How can I make the Visible property of these control buttons be "Yes" depending on the text in a control on the form and "No" if the text is other than the desired text. Any assistance greatly appreciated. |
#8
|
|||
|
|||
Hide or show Control Button on Form in Access 97
Pete,
To deal with the space in the subform name, change the reference to: Me.[Equipment F].Command7.Visible = True The underscore doesn't replace spaces, and I'm actually surpised you didn't get an error message saying Access can't find the control. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, I corrected the code to read as follows: Private Sub Combo3_BeforeUpdate(Cancel As Integer) If Me.Combo3 = "TRID-TBD REV 9.0G" Then Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If End Sub Command Button 7 does not disappear when Combo3 contains something other than TRID-TBD REV 9.0G. In case I didn't previously mention: Combo3 is in the Detail area of the Main Form and Command Button 7 is located in the Form Header of the Sub-Form. Should this make any difference in the code? Am I correct in using the BeforeUpdate event in the Main Form? Should I be using Underscore "_" between characters that have spaces or just put a space, i.e. Equipment F is the name of the sub-form but I am using Equipment_F in the code? Again, thanks for any assistance. Pete I'm sure that once I can get one of the Command Buttons to appear and disappear I should have no problem adding the code for other Command Buttons. "Nikos Yannacopoulos" wrote: Pete, To begin with, apologies for the incomplete code! I missed out the Then: If Me.Combo3 = "TRID-TBD_REV_9.0G" Then etc. Now on to your new question: the code sample I rpovided yesterday for controlling the visibility of multiple buttons assumed they were all subject to the same "specific text" in the combo; if, as I understand now, it's a different text for each, then your code would have to have a separate If/Then/Else structure for each, like: If Me.Combo3 = "TRID-TBD_REV_9.0G" Then Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If If Me.Combo3 = "specific text B" Then Me.Equipment_F.Command8.Visible = True Else Me.Equipment_F.Command8.Visible = False End If If Me.Combo3 = "specific text C" Then Me.Equipment_F.Command9.Visible = True Else Me.Equipment_F.Command9.Visible = False End If 'etc End Sub As I understand, you only want to have one button visible in each case; under the circumstances, a different approach, which I personally find neater, would be to make them all invisible, and then selectively make just one visible, rather than executing a series if If/Then/Else checks, like: Me.Equipment_F.Command7.Visible = False Me.Equipment_F.Command8.Visible = False Me.Equipment_F.Command9.Visible = False 'etc for additional buttons Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Visible = True Case "specific text B" Me.Equipment_F.Command8.Visible = True Case "specific text C" Me.Equipment_F.Command9.Visible = True 'etc for additional buttons End Select End Sub If you want to take this a step further and make your form look more "professional", you could use a single command button, and change its caption and what it does through code, based on the selected value in combo3. To do this, assuming you are only using one button called Command7, your button would always be visible, and the code behind the combo event and the form's current event would be something like: Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Caption = "Do action A..." Case "specific text B" Me.Equipment_F.Command7.Caption = "Do action B..." Case "specific text C" Me.Equipment_F.Command7.Caption = "Do action C..." 'etc for additional cases End Select End Sub Then, the code behind the command button itself would be something like: Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" 'code for action A Case "specific text B" 'code for action B Case "specific text C" 'code for action C 'etc for additional cases End Select End Sub where you could include the actual code in the Select Case structure, or you could just call separate subs that contain the code pertaining to each selection. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, I get - Compile error: Expected: Then or GoTo when I entered the following: Private Sub Form_Current() If Me.Combo3 = "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If End Sub What do I need to do to fix? Where/how would I add a different text for Combo3 above in order to change the visible property of Command8, Command9, etc.. Thanks for your assistance. Pete "Nikos Yannacopoulos" wrote: Pete, To your first question, assuming the subform is called SubForm1, the references to the command buttons on it should change to: Me.SubForm1.Formcmdbutton1 etc, so the code would become: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False End If To do the same for multiple buttons, you could either repeat the line of code after the If / Else keywords, adding one for each button, like: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Me.SubForm1.cmdbutton2.Visible = True Me.SubForm1.cmdbutton3.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False Me.SubForm1.cmdbutton2.Visible = False Me.SubForm1.cmdbutton3.Visible = False End If For a big number of buttons you could employ a loop, but it's unlikely it's your case. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, A couple of other questions - The command buttons in question are contained in the Form Header of a Sub-Form. The control that contains the specific test is located in the Main Form's Detail area. How is this going to affect the way the code is written? How do I add addtional "cmdbutton2, 3, 4, etc"? Unfortunately I have no background in writing code. Thanks for your assistance. "Nikos Yannacopoulos" wrote: Pete, You will need a couple of line of code in the textbox control's Before Update event: If Me.txtbox1 = "specific text" Me.cmdbutton1.Visible = True Else Me.cmdbutton1.Visible = False End If I would suggest you use the same code in the form's On Current event, so the button is made visible.invisible according to the value of the field in each record as you browse through... or you could put the code in a private sub in the form's module, and call it from the two events (so you don't have to repeat it twice). HTH, Nikos "Pete Sperling" wrote in message news I have several control buttons on a form. I would like the control buttons to be hidden unless there is specific text in a control. How can I make the Visible property of these control buttons be "Yes" depending on the text in a control on the form and "No" if the text is other than the desired text. Any assistance greatly appreciated. |
#9
|
|||
|
|||
Hide or show Control Button on Form in Access 97
Nikos - Thanks for your help - Pete
"Nikos Yannacopoulos" wrote: Pete, To deal with the space in the subform name, change the reference to: Me.[Equipment F].Command7.Visible = True The underscore doesn't replace spaces, and I'm actually surpised you didn't get an error message saying Access can't find the control. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, I corrected the code to read as follows: Private Sub Combo3_BeforeUpdate(Cancel As Integer) If Me.Combo3 = "TRID-TBD REV 9.0G" Then Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If End Sub Command Button 7 does not disappear when Combo3 contains something other than TRID-TBD REV 9.0G. In case I didn't previously mention: Combo3 is in the Detail area of the Main Form and Command Button 7 is located in the Form Header of the Sub-Form. Should this make any difference in the code? Am I correct in using the BeforeUpdate event in the Main Form? Should I be using Underscore "_" between characters that have spaces or just put a space, i.e. Equipment F is the name of the sub-form but I am using Equipment_F in the code? Again, thanks for any assistance. Pete I'm sure that once I can get one of the Command Buttons to appear and disappear I should have no problem adding the code for other Command Buttons. "Nikos Yannacopoulos" wrote: Pete, To begin with, apologies for the incomplete code! I missed out the Then: If Me.Combo3 = "TRID-TBD_REV_9.0G" Then etc. Now on to your new question: the code sample I rpovided yesterday for controlling the visibility of multiple buttons assumed they were all subject to the same "specific text" in the combo; if, as I understand now, it's a different text for each, then your code would have to have a separate If/Then/Else structure for each, like: If Me.Combo3 = "TRID-TBD_REV_9.0G" Then Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If If Me.Combo3 = "specific text B" Then Me.Equipment_F.Command8.Visible = True Else Me.Equipment_F.Command8.Visible = False End If If Me.Combo3 = "specific text C" Then Me.Equipment_F.Command9.Visible = True Else Me.Equipment_F.Command9.Visible = False End If 'etc End Sub As I understand, you only want to have one button visible in each case; under the circumstances, a different approach, which I personally find neater, would be to make them all invisible, and then selectively make just one visible, rather than executing a series if If/Then/Else checks, like: Me.Equipment_F.Command7.Visible = False Me.Equipment_F.Command8.Visible = False Me.Equipment_F.Command9.Visible = False 'etc for additional buttons Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Visible = True Case "specific text B" Me.Equipment_F.Command8.Visible = True Case "specific text C" Me.Equipment_F.Command9.Visible = True 'etc for additional buttons End Select End Sub If you want to take this a step further and make your form look more "professional", you could use a single command button, and change its caption and what it does through code, based on the selected value in combo3. To do this, assuming you are only using one button called Command7, your button would always be visible, and the code behind the combo event and the form's current event would be something like: Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Caption = "Do action A..." Case "specific text B" Me.Equipment_F.Command7.Caption = "Do action B..." Case "specific text C" Me.Equipment_F.Command7.Caption = "Do action C..." 'etc for additional cases End Select End Sub Then, the code behind the command button itself would be something like: Select Case Me.Combo3 Case "TRID-TBD_REV_9.0G" 'code for action A Case "specific text B" 'code for action B Case "specific text C" 'code for action C 'etc for additional cases End Select End Sub where you could include the actual code in the Select Case structure, or you could just call separate subs that contain the code pertaining to each selection. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, I get - Compile error: Expected: Then or GoTo when I entered the following: Private Sub Form_Current() If Me.Combo3 = "TRID-TBD_REV_9.0G" Me.Equipment_F.Command7.Visible = True Else Me.Equipment_F.Command7.Visible = False End If End Sub What do I need to do to fix? Where/how would I add a different text for Combo3 above in order to change the visible property of Command8, Command9, etc.. Thanks for your assistance. Pete "Nikos Yannacopoulos" wrote: Pete, To your first question, assuming the subform is called SubForm1, the references to the command buttons on it should change to: Me.SubForm1.Formcmdbutton1 etc, so the code would become: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False End If To do the same for multiple buttons, you could either repeat the line of code after the If / Else keywords, adding one for each button, like: If Me.txtbox1 = "specific text" Me.SubForm1.cmdbutton1.Visible = True Me.SubForm1.cmdbutton2.Visible = True Me.SubForm1.cmdbutton3.Visible = True Else Me.SubForm1.cmdbutton1.Visible = False Me.SubForm1.cmdbutton2.Visible = False Me.SubForm1.cmdbutton3.Visible = False End If For a big number of buttons you could employ a loop, but it's unlikely it's your case. HTH, Nikos "Pete Sperling" wrote in message ... Nikos, A couple of other questions - The command buttons in question are contained in the Form Header of a Sub-Form. The control that contains the specific test is located in the Main Form's Detail area. How is this going to affect the way the code is written? How do I add addtional "cmdbutton2, 3, 4, etc"? Unfortunately I have no background in writing code. Thanks for your assistance. "Nikos Yannacopoulos" wrote: Pete, You will need a couple of line of code in the textbox control's Before Update event: If Me.txtbox1 = "specific text" Me.cmdbutton1.Visible = True Else Me.cmdbutton1.Visible = False End If I would suggest you use the same code in the form's On Current event, so the button is made visible.invisible according to the value of the field in each record as you browse through... or you could put the code in a private sub in the form's module, and call it from the two events (so you don't have to repeat it twice). HTH, Nikos "Pete Sperling" wrote in message news I have several control buttons on a form. I would like the control buttons to be hidden unless there is specific text in a control. How can I make the Visible property of these control buttons be "Yes" depending on the text in a control on the form and "No" if the text is other than the desired text. Any assistance greatly appreciated. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating a Form. Should I use Control or Form Toolbar? | Amy | General Discussion | 7 | July 1st, 2004 02:36 PM |
How to assign value to a report control? | Peter | General Discussion | 3 | June 29th, 2004 11:17 AM |
option button value in word form | Optbutton | General Discussion | 0 | June 16th, 2004 05:59 PM |
Restricting entries in a ComboBox | tina | General Discussion | 5 | June 14th, 2004 05:13 PM |
Linking Excel data through Access to use a Form as an Interface | Laura | Links and Linking | 0 | March 23rd, 2004 04:59 PM |