473,323 Members | 1,537 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,323 software developers and data experts.

Questions about Access 2000 & forms

good morning guys,

I have a Form composed of the following fields named:

"YY" (checkbox)
"X1", "X2", "X3" (datefields).

The question is: how can I manage the fields X1,X2,X3 so that they must be enabled only when checkbox "YY" is checked (true) ??

Please, could anybody give me the specific instructions to resolve the problem ??

Thank you very much in advance.

bye, Sandro54
Jan 27 '08 #1
6 1158
Good morning Guys,

I have a form of Access 2000 composed of the following fields named:

"YY" (checkbox)

"X1", "X2", "X3" (datefields).

The OS is Windows XP.

The question is: how can I manage the fields X1;X2;X3 so that they must be enabled only when checkbox "YY" is checked (true) ??.

Please, could anybody give me the specific instructions to resolve the problem ??

Thank you very much in advance.

bye
Sandro54
Hi Sandro,

To make the textboxes X1, X2 & X3 only able to accept data entry when Checkbox YY has been checked:
  1. Set all the textboxes enabled properties to false.
  2. Use the click event of Checkbox YY to switch the enabled property of the X Checkboxes with this code:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub YY_Click
    2.     If YY = True Then
    3.         X1.Enabled = True
    4.         X2.Enabled = True
    5.         X3.Enabled = True
    6.     Else
    7.         X1.Enabled = False
    8.         X2.Enabled = False
    9.         X3.Enabled = False
    10.     End If
    11. End Sub
This will prevent data entry when every checkbox YY is unchecked.

Hope this helps.

Kind Regards,
Ken Farrawell.
Jan 27 '08 #2
missinglinq
3,532 Expert 2GB
When writing this kind of code, you also need to place it in the Form_Current event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If YY = True Then
  3.  
  4.   X1.Enabled = True
  5.  
  6.   X2.Enabled = True
  7.  
  8.   X3.Enabled = True
  9.  
  10. Else
  11.  
  12.   X1.Enabled = False
  13.  
  14.   X2.Enabled = False
  15.  
  16.   X3.Enabled = False
  17.  
  18. End If
  19.  
  20. End Sub
  21.  
With the code only in the OnClick event, if you check YY on Record A, it enables the textboxes. If you then move to Record B, the textboxes will still be enabled, even if YY on this record is unchecked! Running the code in Form_Current addresses this problem.

Welcome to TheScripts, Sandro54!

Linq ;0>
Jan 27 '08 #3
sierra7
446 Expert 256MB
Hi Sandro54
The simplest way is to run some code in the On_Current event of the form
Expand|Select|Wrap|Line Numbers
  1. If Me!YY = True Then
  2.     Me!X1.Enabled = True
  3.     Me!X2.Enabled = True
  4.     Me!X3.Enabled = True
  5. Else
  6.     Me!X1.Enabled = False
  7.     Me!X2.Enabled = False
  8.     Me!X3.Enabled = False
  9. End If
However, if you check or uncheck 'YY' you will probably want an immediate result, so paste the same code into the After_Update event of 'YY'.

This will meet the requirement of your question but it will 'grey-out' the dis-abled fields, which might be OK for you but you might want to consider an alternative;
locking the fields and changing the back-colour. The following code will make the fields 'pale yellow' when locked but white when unlocked to recieve data.

Expand|Select|Wrap|Line Numbers
  1. Dim lngLocked as Long
  2. lngLocked = 8454143   'pale yellow
  3.  
  4. If Me!YY = True Then
  5.     Me!X1.Locked= False
  6.     Me!X2.Locked= False
  7.     Me!X3.Locked= False
  8.     Me!X1.Backcolor = vbWhite
  9.     Me!X2.Backcolor = vbWhite
  10.     Me!X3.Backcolor = vbWhite
  11. Else
  12.     Me!X1.Locked= True
  13.     Me!X2.Locked= True
  14.     Me!X3.Locked= True
  15.     Me!X1.Backcolor = lngLocked
  16.     Me!X2.Backcolor = lngLocked
  17.     Me!X3.Backcolor = lngLocked
  18. End If
If you have more than three fields you may want to write two seperate sub-routines 'LockFields' and 'UnLockField'
Expand|Select|Wrap|Line Numbers
  1. Private Sub LockFields()
  2. Dim lngLocked as Long
  3. lngLocked = 8454143   'pale yellow
  4.  
  5.     Me!X1.Locked= True
  6.     Me!X2.Locked= True
  7.     Me!X3.Locked= True
  8.     Me!X1.Backcolor = lngLocked
  9.     Me!X2.Backcolor = lngLocked
  10.     Me!X3.Backcolor = lngLocked
  11. end sub
You can write your own Unlock sub., then the code On_Current would be
Expand|Select|Wrap|Line Numbers
  1. If Me!YY = True Then
  2.    UnlockFields
  3. Else
  4.    LockFields
  5. Endif
I hope thi shelps

S7
Jan 27 '08 #4
missinglinq
3,532 Expert 2GB
Sandro54: You posted this question twice this morning, 18 minutes apart, and thus have wasted the time of some of our members! Double posting is strictly forbidden here as it is on all forums! Please refrain from this behavior in the future!

From FAQs

Do Not Double Post Your Questions

Double posting is where you start a thread on a topic and then for some reason start another thread on exactly the same topic in the same forum. Please do not do this because

1. It makes it very hard for people to answer you especially if there are answers happening in all the threads you have started because they have to read 2 or more threads in order to see what has already been said.
2. It swamps the forum with your problem resulting in less attention for the other threads.

If you feel for some reason that you post has been overlooked (for instance it hasn't had any replies) please do not repost the question. Post a message to the thread you started, this will bump it back to the top of the thread list for the forum.

Thank you for your attention in this matter.

Linq ;0)>

Moderator
Jan 27 '08 #5
Sandro54: You posted this question twice this morning, 18 minutes apart, and thus have wasted the time of some of our members! Double posting is strictly forbidden here as it is on all forums! Please refrain from this behavior in the future!

From FAQs

Do Not Double Post Your Questions

Double posting is where you start a thread on a topic and then for some reason start another thread on exactly the same topic in the same forum. Please do not do this because

1. It makes it very hard for people to answer you especially if there are answers happening in all the threads you have started because they have to read 2 or more threads in order to see what has already been said.
2. It swamps the forum with your problem resulting in less attention for the other threads.

If you feel for some reason that you post has been overlooked (for instance it hasn't had any replies) please do not repost the question. Post a message to the thread you started, this will bump it back to the top of the thread list for the forum.

Thank you for your attention in this matter.

Linq ;0)>

Moderator

I apologize for having submitted the same question twice. This is the first time I used your forum and I were not sure where to insert a new post and therefore I erroneously initiated a new discussion before discovering where to place the post. Again, my apologies.
Anyway thanks a lot for your invaluable support.
Jan 28 '08 #6
Hi Sandro,

To make the textboxes X1, X2 & X3 only able to accept data entry when Checkbox YY has been checked:
  1. Set all the textboxes enabled properties to false.
  2. Use the click event of Checkbox YY to switch the enabled property of the X Checkboxes with this code:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub YY_Click
    2.     If YY = True Then
    3.         X1.Enabled = True
    4.         X2.Enabled = True
    5.         X3.Enabled = True
    6.     Else
    7.         X1.Enabled = False
    8.         X2.Enabled = False
    9.         X3.Enabled = False
    10.     End If
    11. End Sub
This will prevent data entry when every checkbox YY is unchecked.

Hope this helps.

Kind Regards,
Ken Farrawell.

Thank you for your assistance on this problem, it helped me a lot.
Jan 28 '08 #7

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

Similar topics

2
by: Matthew Clement | last post by:
I'm currently building a form (called frmReports) to set the criteria for a query, but I'm having some trouble with syntax and hope that one of the guru's here can help me achieve what I'm do. ...
15
by: WStoreyII | last post by:
First Question: Due to the hours of my job i can not go to school right now and i can't afford online classes. My questions is that i have learned a lot about .net and i am pretty sure that if...
2
by: egoldthwait | last post by:
I need to convert a 17mb access 2000 db to Oracle and house it in a Citrix farm. The issue: we have never converted an Access Db to Oracle but can probably use Oracle's Workbench to assist with...
1
by: Ron | last post by:
Hi All, First question is what to do if somehow security was run on a database I've designed and yet I have NO idea how or when it was run? There is a "system1.mdw" file sitting there, and I...
4
by: ThePhenix | last post by:
Hi everybody, I have recently been doing a conversion for my boss for a access 2000 database (both front and backend) to a MSSQL backend. I finished the conversion today (as quite a lot of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.