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

greying out fields

1
I'm a newbie at Access and am trying to get fields (like 'cs_compl', 'ec_compl', etc) in a form to grey out depending on the value entered into the 'type' field. However, 'type' is a calculated field dependent on the the value entered in the 'barcode' field. I'm using the following code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub barcode_AfterUpdate()
  2.     Me.cs_compl.Enabled = (Me.type.AfterUpdate <= 4 Or Me.type.AfterUpdate = 6 Or 7 Or 8)
  3.     cm_compl.Enabled = (Me.type.AfterUpdate <= 4 Or Me.type.AfterUpdate = 6 Or 7 Or 8)
  4.     ec_compl.Enabled = (4 <= Me.type.AfterUpdate >= 6)
  5.     Me.en_compl.Enabled = (Me.type.AfterUpdate = 1 Or 8)
  6.     Me.pe_compl.Enabled = (Me.type.AfterUpdate = 3 Or 4)
  7.     Me.uf_compl.Enabled = (Me.type.AfterUpdate = 3)
  8.     Me.ad_compl.Enabled = (4 <= Me.type.AfterUpdate >= 6)
  9. End Sub
Thanks for any advice!
Dec 9 '11 #1
2 1557
NeoPa
32,556 Expert Mod 16PB
Unfortunately, you don't include the logic you want implemented in your question, but I'll try to reverse engineer this code and see what I can come up with. Next time please remember to ask the whole question fully if you'd like someone to spend their time trying to help you.

Try this :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Barcode_AfterUpdate()
  2.     With Me
  3.         .cs_compl.Enabled = (.Type <= 4) Or _
  4.                             (.Type = 6) Or _
  5.                             (.Type = 7) Or _
  6.                             (.Type = 8)
  7.         .cm_compl.Enabled = .cs_compl.Enabled
  8.         .ec_compl.Enabled = (.Type >= 4) And (.Type <= 6)
  9.         .en_compl.Enabled = (.Type = 1) Or (.Type = 8)
  10.         .pe_compl.Enabled = (.Type = 3) Or (.Type = 4)
  11.         .uf_compl.Enabled = (.Type = 3)
  12.         .ad_compl.Enabled = .ec_compl.Enabled
  13.     End With
  14. End Sub
If it works, look at the code and see why.
Dec 9 '11 #2
TheSmileyCoder
2,322 Expert Mod 2GB
2 things you seem to have misunderstood:
Me.type.AfterUpdate is not the value of the textbox Type, after it is updated. Me.type.AfterUpdate is a PROPERTY, the same property that you can see specified in the Events TAB of your control. In your case it might read [EVENT PROCEDURE]

Second you make a comparison:
Expand|Select|Wrap|Line Numbers
  1. Me.type.AfterUpdate = 6 Or 7 Or 8
Which should further to the above have looked:
Expand|Select|Wrap|Line Numbers
  1. Me.type = 6 Or 7 Or 8
or
Expand|Select|Wrap|Line Numbers
  1. Me.type.Value= 6 Or 7 Or 8
The .Value is not necessary as .Value is the default property of the control.

Not quite done yet. Another (common) misunderstanding is that your code will compare Me.type to 6, 7 and 8. What really is happening is that you are comparing Me.type to 6, and then using the or operator between your comparision (which will be true or false) and 7 and 8. For the program it would look like this:
Expand|Select|Wrap|Line Numbers
  1. TRUE or 7 or 8
  2. FALSE or 7 or 8
To make the correct comparision that I believe you are after you should use:
Expand|Select|Wrap|Line Numbers
  1. Me.type = 6 Or Me.type = 7 Or Me.type = 8
or of course the code that NeoPa have provided for you.
Dec 12 '11 #3

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

Similar topics

2
by: Tim Cowan | last post by:
Hi I am trying to create a CSV file with some fields in double quotes ("). I am not having any luck. This is what I want; "8684","COSTING","000010001","REG",X4,15.00, ,14,0,14,9,6 I am...
3
by: Rob Dixon | last post by:
Hi. Am I missing something, or is there no way of greying out irrelevant form fields on the basis of the contents of the rest of the form? Thanks, Rob
0
by: bill mahoney | last post by:
I have access 2k and I have 2 tables. One is a 7X6 table representing a month with zeroes padding the fields where no day exist. For example February 2003 0 0 0 0 0 0 1 2 3 4 5 6 7 ...
4
by: Melissa | last post by:
I have a frontend file named CustomerApp and backend file named CustomerData. CustomerApp is at C:\Customer Database and CustomerData is at S:\Customer Database. Could someone help me with the code...
5
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
5
by: Genboy | last post by:
My "VIS" Website, which is a C# site created in VS.NET, Framework 1.1, is no longer compiling for me via the command line. As I have done 600 times in the last year and a half, I can compile to...
9
by: sean.scanlon | last post by:
can someone help understand how i can could access a struct field dymanically like: foo->fields ? when i try to compile this i get the following error: 'struct pwd' has no member named 'fields'...
482
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. ...
8
!NoItAll
by: !NoItAll | last post by:
I am retrieving data from an MS SQL database using SQL2000 on Windows XP. I am using VB6. I am having a very odd problem with certain fields returning empty - when they are not. Here is my code:...
5
by: John Boyd | last post by:
I know I can post to page 2 but the problem is I need to capture the name, email (optional), and referral source. If i post to page 2 then it simply asks for the required fields. If I do get it...
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: 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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.