Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 21st, 2005, 06:50 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
:)

Reply With Quote
  #2 (permalink)  
Old June 21st, 2005, 07:18 AM
Friend of Wrox
Points: 4,007, Level: 26
Points: 4,007, Level: 26 Points: 4,007, Level: 26 Points: 4,007, Level: 26
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Lansing, Michigan, USA.
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

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
Reply With Quote
  #3 (permalink)  
Old June 21st, 2005, 07:27 AM
Registered User
 
Join Date: Jun 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thankyou Greg, the first suggestion worked like a charm!! Many Thanks!! =)

Reply With Quote
  #4 (permalink)  
Old February 10th, 2007, 03:47 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
  #5 (permalink)  
Old February 10th, 2007, 08:43 PM
Registered User
 
Join Date: Feb 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using JS to enable/disable?? crabjoe Javascript 4 November 10th, 2008 06:48 PM
Enable Update and Enable Delete check boxes don't mihabib ASP.NET 2.0 Basics 2 December 7th, 2006 11:44 AM
Disable and Enable at runtime Hammam ASP.NET 1.0 and 1.1 Professional 0 May 17th, 2006 12:40 AM
Access VBA - Controlling Text boxes in a form Scripts82 Access VBA 4 February 8th, 2006 08:35 PM
Disable/Enable elements ldoodle Javascript How-To 3 June 7th, 2005 05:48 AM



All times are GMT -4. The time now is 10:46 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.