Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / April 2008

Tip: Looking for answers? Try searching our database.

Disabling Text box controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Carlos1815 - 09 Apr 2008 00:16 GMT
I have a project where I would like the text box controls of a form to
be disabled according to the choice made from a combo box.  I've seen
questions similar to this many times in this forum, but none of the
answers seem to work for me.  Here's what I have:

A form with text box controls to enter data.  I also have a combo box
with two choices.  Choice A, all the text box controls are Enabled.
If Choice B is chosen, I would like all the text boxes to be disabled
and greyed out, but only for those records that have "Choice B"; all
other records that have "Choice A" in the combo box, I would like to
leave the text boxes enabled.

On the combo box After Update event, I have this code (cboPageType is
the combo box, and PageName and Text are the names of two of the text
boxes I would like disabled upon choosing "Choice B", which in this
case is "CompCheck_Page"):

Private Sub cboPageType_AfterUpdate()
 If Me.cboPageType = "CompCheck_Page" Then
      Me.PageName.Enabled = False
      Me.Text.Enabled = False
   Else
       Me.PageName.Enabled = True
       Me.Text.Enabled = True
 End If
End Sub

However, nothing happens when I choose "Choice B" or "Choice A"; as if
the code doesn't exist.  The combo box is bound to a separate table
with the two choices in it.  I think that's all the information I
have.  If anyone can see an answer to this conunudrum, I would
appreciate any help!  Thank you.

Carlos
Linq Adams - 09 Apr 2008 01:11 GMT
It worked without problem for me!

The obvious; are all your names spelled correctly? Is CompCheck_Page the
exact spelling of this choice?

What exactly do you mean by

However, nothing happens when I choose "Choice B" or "Choice A"

The controls have to be either enabled or disabled to begin with, so only one
choice should do something, right? .

From Form Design View, select the combobox then goto  Properties - Events.
Does [Event Procedure] appear next to the AfterUpdate Property? If not, click
in the box, select Build Code. This should take you to the AfterUpdate sub.
Exit the code module and run the form again.

Lastly, I guess you have to think about a corrupted combobox.

BTW, you should change the name of your textbox from Text to something else;
Text is a reserved word in Access.

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Linq Adams - 09 Apr 2008 01:13 GMT
Forgot to add, in order for the enable/disable to be maintained as you move
from record to record, the same code needs to be in the form's OnCurrent
event as well as the AfterUpdate event.

>It worked without problem for me!
>
[quoted text clipped - 17 lines]
>BTW, you should change the name of your textbox from Text to something else;
>Text is a reserved word in Access.

Signature

There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Carlos1815 - 09 Apr 2008 21:19 GMT
On Apr 8, 8:13 pm, "Linq Adams via AccessMonster.com" <u28780@uwe>
wrote:
> Forgot to add, in order for the enable/disable to be maintained as you move
> from record to record, the same code needs to be in the form's OnCurrent
[quoted text clipped - 30 lines]
>
> - Show quoted text -

Thank you for your prompt help!  Unfortunately, nothing is fixed.  I
changed the name of the text boxes, PageName and Text to Screentitle
and InstructionalText respectively.  The code for the cbo box After
Update now looks like this:

Private Sub cboPageType_AfterUpdate()
 If Me.cboPageType = "CompCheck_Page" Then
      Me.ScreenTitle.Enabled = False
      Me.InstructionalText.Enabled = False
   Else
       Me.ScreenTitle.Enabled = True
       Me.InstructionalText.Enabled = True
 End If
End Sub

I also made sure to make the name changes in the Table, as well.  The
name of the combo box and the contents of the cbo box remain the
same.  I also made sure to add that previous code into the form's
OnCurrent event.  The [Event Procedure] is present in the cbo box's
After Update and the form's On Current properties.

To clear up what I described previously, what I have is a form with
all text controls enabled; this is the default setting for the whole
form.  What I would like to have is certain text box controls disabled
when Choice B from the cbo box is chosen for that record.  So maybe in
records 1 through 7, Choice A is chosen from the cbo box and are
normal and text boxes enabled, but record 8 has Choice B chosen in the
cbo box, so I would like certain text boxes disabled for that record
only and for any other records where Choice B is chosen from the cbo
box.

How would I know if the cbo box is corrupted?  Other than it not
working?

As an addendum, I would like to have the same functionality with a
button; making it invisible until Choice B is chosen on the cbo box.
I tried making a button and coding it to be invisible until the cbo
box event, but that doesn't work, either.  The button remains
invisible regardless; I'd have to make it visible by switching the
Visible property to "yes".

I don't know if this matters, but I'm using Access 2002.

Thanks again!
Carlos
Carlos1815 - 09 Apr 2008 21:30 GMT
> On Apr 8, 8:13 pm, "Linq Adams via AccessMonster.com" <u28780@uwe>
> wrote:
[quoted text clipped - 81 lines]
>
> - Show quoted text -

I found the problem!  There were two columns in the Table bound to the
cbo box, I had the code refer to the wrong column.  I set it to
recognize the correct column in the Table, and the form functions like
I mentioned.  Thanks for your insight!

Carlos
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.