473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Visual Basic code for enabling and disabling text boxes in MS Access?

Hello all,

I have been having some troubles figuring out how to do this. Naturally, I have looked through this forum and countless others, all yielding the same answers to my question... which for some reason I cannot get to work. I can't quite figure out what I'm doing wrong here.

I am in the process of creating a search form that searches through a database using different parameters. This parameters are text boxes. Next to the text boxes are checkboxes. For example, I would like to have Text1 enabled when Checkbox1 is checked. Here is what I have so far:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Check1_AfterUpdate()
  2. If Me.Check1 = True Then
  3. Me.text1.Enabled = True
  4. Else
  5. Me.text1.Enabled = False
  6. End If
  7. End Sub
  8.  
Keep in mind that I am doing this in MS Access 2007.

I am open to any suggestions and greatly appreciate any help.

Thanks,
VBnewb13
Jun 28 '10 #1

✓ answered by patjones

In the form's On Open event you could certainly say Me.check1 = 0, or set it in the properties sheet in form design view.

Pat

5 3353
patjones
931 Expert 512MB
Expand|Select|Wrap|Line Numbers
  1. Private Sub Check1_AfterUpdate()
  2.    Me.text1.Enabled = Me.Check1
  3. End Sub

When I do this, I usually set the text box's default state to not enabled so that when the form first opens, it corresponds to the check box being unchecked. Alternatively you could set the check box default to checked. Either way, make sure the states correspond to each other on form open.

Pat
Jun 29 '10 #2
That is brilliant, I see exactly what you are saying. I really can't get it to work for some reason. I'll detail exactly what I have set up:

I have a form. On this form I have text1 and check1. I have the exact code you suggested.

How do I set the default value of check1 to off.
Me.check1.value = 0 ?
Or what do I type in the data section of properties where it says default value?

Thanks again
Jun 29 '10 #3
patjones
931 Expert 512MB
In the form's On Open event you could certainly say Me.check1 = 0, or set it in the properties sheet in form design view.

Pat
Jun 29 '10 #4
vb5prgrmr
305 Expert 100+
In VB, we have a constant...
Expand|Select|Wrap|Line Numbers
  1. If Me.Check1.Value = vbChecked Then
  2. '...
  3.  
So I wonder if you have the same in VBA...



Good Luck
Jun 30 '10 #5
I figured it out. I had to enable some security options I guess. That's why when I initially created something it worked, but when I closed the db and reopened it nothing would work.

thanks for your help though, it worked out great :)
Jul 1 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Gary | last post by:
Hello All, I have an editable data grid in my web form, this grid allows the user to add new records, edit existing records and also delete them. When a user adds a record the grid goes in to...
0
by: CrAn57 | last post by:
I'm using Visual Studio .net, and am programming a web form in Visual Basic (including the HTML page, and the VB code behind page). I have a flash .swf on the HTML side of the page, but want to...
3
by: powelly | last post by:
This is my first time not sure whats needed this is XP office this is the code i`m trying to run i have tried on close and command buttons i don`t even get an error code just does not run Dim...
2
by: sbweld | last post by:
Hello, I am using Powerpoint 2007 and have found an option to integrate visual basic code into the slides. I am building a standalone Kiosk and I want my powerpoint presentation to reset and go...
7
by: harig | last post by:
hi all, i've five text boxes followed by a check box ..... when i check the checkbox it shud disable all the text boxes.... when i uncheck it the vice-versa shud happen.. how do i do it????...
1
by: AMK2701 | last post by:
Hi, I am just new at using this code, so have probably made a really simple mistake. My code works fine just in the sub form I created it, but when putting the sub form in the main form, the code...
4
by: raaman rai | last post by:
guys, what is the idea to backup sql server databse via visual basic code. And i also want the code please.
0
by: Serenityquinn15 | last post by:
Hi! I have two Table names: tblupdate tblDetails What i want to do is to update the table tblupdate from tblDetails using the button in Visual basic Interface.
2
by: paliko | last post by:
a Visual basic code for an online tax payment system
1
by: vinayreddy | last post by:
How to see visual basic code of ms access file inorder to change the path of the database resides. Please any body can provide solution for this.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.