|
|
 |
| Access VBA Discuss using VBA for Access programming. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

June 21st, 2005, 07:50 AM
|
|
Registered User
|
|
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Help with VBA Disable/Enable text boxes
Hi,
I'm a SQL programmer mainly, and have never really worked with VBA before. However, I have been tasked with building an access database. Basically, what I am trying to do is on one of the forms there are a set of questions to be answered ("Yes" and "No"). If certain questions are answered in a certain way I want to stop users from entering information into certain other questions. I've looked in a few books and have come up with this code (which I attach as an Event Procedure against AfterUpdate in the properties of the field)
Private Sub PaidEmploy_AfterUpdate()
If DataEntry!PaidEmploy = "Yes" Then
DataEntry!WorkEx.Enabled = False
DataEntry!WorkEx.Locked = True
Else
DataEntry!WorkEx.Enabled = True
DataEntry!WorkEx.Locked = False
End If
End Sub
However, when I run the form it gives me the following error in the debugger;
"Compile Error;
Qualifier must be collection"
Can anyone help me on this please, it would be most appreciated!!!
Thanks
:)
|

June 21st, 2005, 08:18 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,114
Thanks: 2
Thanked 4 Times in 4 Posts
|
|
Hi, your code is not too far off. It depends what exactly the control PaidEmploy is. Is it a checkbox or a textbox or a combobox?
Textbox or combobox:
If Me.PaidEmploy = "Yes" Then
Me.WorkEx.Enabled = False
Else
Me.WorkEx.Enabled = True
End If
or simply
Me.PaidEmpoy.Enabled = Not (Me.PaidEmploy = "Yes")
If it's a checkbox then
If Me.PaidEmploy Then
Me.WorkEx.Enabled = False
Else
Me.WorkEx.Enabled = True
End If
or simply
Me.WorkEx.Enabled = Not Me.PaidEmploy
The expression "Me." is a shortcut for "Forms!DataEntry.Form." assuming "DataEntry" is the name of your form.
There's no need to lock WorkEx. When you disable AND lock it, it doesn't appear "grayed out." That's a good indicator to the user that's it's disabled.
Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
|

June 21st, 2005, 08:27 AM
|
|
Registered User
|
|
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thankyou Greg, the first suggestion worked like a charm!! Many Thanks!! =)
|

February 10th, 2007, 03:47 PM
|
|
Registered User
|
|
Join Date: Feb 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am basically trying to do the same thing. Based on what is selected in an option group, text boxes will be enabled/disabled. For example... If DHCP is clicked then only IP Address is enabled, if Static is checked then Ip Address, Subnet Mask, and Default Gateway are enabled. Any help would be appreciated.
|

February 10th, 2007, 08:43 PM
|
|
Registered User
|
|
Join Date: Feb 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
OK i got what i was trying to do to work... i should have done more research before i posted. But there is a bug that would make me needing this pointless... example:
When i click DHCP it changes all the records to DHCP... when i click Static it changes all records to static... AND if i open the form when DHCP is selected, it doesn't disable the boxes until i select Static then DHCP again... if anybody has fix for this it would be great. i hardly know anything about vba... all i know is what i want to do then altering sample code until i get it to work.
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |