473,738 Members | 11,146 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Backwards code works Forwards? Why?

135 New Member
I quickly put this code together to test if it would disable some of my functions OnChange when my text box (purchase order number) is empty...and if it would enable those functions when I added data to my field. The funny thing is that if you read the code it actually runs in reverse! When my field is null it is suppose to disable...inste ad it enables...Why? So I put my code in to do the opposite of what I want and it works!?!?! I don't mind having my code in logical reverse as long as I get the results I'm looking for...but...I don't get it....???? ;-)


Forwards: (works in reverse and enables features when Null)
Expand|Select|Wrap|Line Numbers
  1. Private Sub PurchaseOrderNumber_Change()
  2. If IsNull(Me.PurchaseOrderNumber) Then
  3. Me.Check107.Enabled = False
  4. Me.Check111.Enabled = False
  5. Me.Text77.Enabled = False
  6. Me.Label119.Visible = True
  7. Else
  8. Me.Check107.Enabled = True
  9. Me.Check111.Enabled = True
  10. Me.Text77.Enabled = True
  11. Me.Label119.Visible = False
  12. End If
  13.  
  14. End Sub
Backwards: (disables features when null)
Expand|Select|Wrap|Line Numbers
  1. Private Sub PurchaseOrderNumber_Change()
  2. If IsNull(Me.PurchaseOrderNumber) Then
  3. Me.Check107.Enabled = True
  4. Me.Check111.Enabled = True
  5. Me.Text77.Enabled = True
  6. Me.Label119.Visible = False
  7. Else
  8. Me.Check107.Enabled = False
  9. Me.Check111.Enabled = False
  10. Me.Text77.Enabled = False
  11. Me.Label119.Visible = True
  12. End If
  13.  
  14. End Sub
May 17 '09 #1
18 2031
FishVal
2,653 Recognized Expert Specialist
Hello.

I suggest you to perform a little experiment - add two controls on the form and in PurchaseOrderNu mber_Change event handler assign PurchaseOrderNu mber.Value property and PurchaseOrderNu mber.Text property values to them.

Regards,
Fish.
May 17 '09 #2
MyWaterloo
135 New Member
@FishVal
Ooook that was interesting.... .So....what is that showing me. A little bizarre, but I have no idea what these results tell me... =-)




"So, where did you learn Access?"

"Learn Access? Who? Me?"
May 17 '09 #3
FishVal
2,653 Recognized Expert Specialist
@MyWaterloo
I guess it explains why your code behaves in a way you don't expect.

Kind regards,
Fish.
May 17 '09 #4
MyWaterloo
135 New Member
@FishVal
I don't understand how it explains what my code is doing. Why do the two controls behave the way they do? Why does the code work, but in a way that appears to be in reverse? I just don't see how the two controls reveal why the code behaves the way it does.






"I can design a fantastic looking form for you. With buttons and menus and everything."
"What do they do?"
"What?"
"The buttons and menus."
"I have no idea, but they sure look good."
May 17 '09 #5
MyWaterloo
135 New Member
OK. I see that (for whatever reason I don't know) this current process of mine will not work. I guess I'm at a dead end. I was hoping to disable certain features if one of my fields was not filled in i.e. null. =(
May 17 '09 #6
FishVal
2,653 Recognized Expert Specialist
@MyWaterloo
I think it is quite straightforward .

PurchaseOrderNu mber.Value property is a default property you implicitly invoke when checking condition for enabling/disabling.
This little experiement shows you what this property returns when PurchaseOrderNu mber_Change event fires thus making clear why the code behaves the way it behaves. At the same time value returned by PurchaseOrderNu mber.Text property is , I guess, a more relevant criteria for making decision whether the controls should be enabled or disabled.

Does it make more sense now?
May 17 '09 #7
MyWaterloo
135 New Member
Yes, it kind of makes sense to me. I guess what it really means is that I need to come up with some other way to disable my print buttons if my P.O. number field is null. Any ideas? (Thanks for the lesson.)
May 17 '09 #8
mshmyob
904 Recognized Expert Contributor
subscribing just to watch the fun.

cheers,
May 17 '09 #9
NeoPa
32,569 Recognized Expert Moderator MVP
Did the values ever get posted?

Fish & the OP seem to be discussing something they can both see but I for one, don't see any values posted (Emperor's clothes! I was never one to try to hide my ignorance so I will always ask the questions).
May 18 '09 #10

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

Similar topics

8
17084
by: Chris | last post by:
Can anybody help. I need to read a txt file backwords line by line. Can anybody help me do this. Thanks Chris
7
17460
by: Jay | last post by:
I have a very large text file (being read by a CGI script on a web server), and I get memory errors when I try to read the whole file into a list of strings. The problem is, I want to read the file backwards, starting with the last line. Previously, I did: myfile = open('myfile.txt', 'r') mylines = myfile.readlines() myfile.close()
15
3615
by: SK | last post by:
Hey folks, I am searching for a string (say "ABC") backwards in a file. First I seek to the end. Then I try to make a check like - do { file.clear (); file.get(c); file.seekg(-2, std::ios::cur);
11
3076
by: Matt DeFoor | last post by:
I have some log files that I'm working with that look like this: 1000000000 3456 1234 1000000001 3456 1235 1000020002 3456 1223 1000203044 3456 986 etc. I'm trying to read the file backwards and just look at the first column. Here's what I've got so far:
6
44089
by: Neil Patel | last post by:
I have a log file that puts the most recent record at the bottom of the file. Each line is delimited by a \r\n Does anyone know how to seek to the end of the file and start reading backwards?
3
4411
by: Adrian | last post by:
> Hi > > I'm lost! so please help me... > > I have the following code > > I want to simply retrieve all the record that matches the SQL statement, I > want to know how many records matched and display only one field adata > from each match but also be able to step forward and backwards?! >
1
2216
by: Orestis Markou | last post by:
Hello, I'm the developer of PySmell ( http://github.com/orestis/pysmell ), a static analysis/intellisense provider for Python. I am targeting Python 2.4 code so I'm using the compiler package. I've been toying around yesterday with the ast module in Python 2.6 and it seems much more cleaner. One thing I don't understand is how should one handle backwards and forwards compatibility.
0
160
by: Terry Reedy | last post by:
Orestis Markou wrote: My impression is that the 2.6 ast package is quite different from the 2.4 compiler package, but I have not looked at it (in its 3.0 version) yet. If the 2.4 code you are analyzing is syntactically and sematically valid as 2.6 code, which I believe is usual, then of course there is no problem. If it is not, then I would not be sure. If you want to target 2.3 to 3.0, 2.6 is the only option as far as I
0
1938
by: chromis | last post by:
Hi, I'm creating virtual tour of a house, the part I am working on at the moment involves a 360 spin view of the house (a series of 36 flat frames). Each corner of the house has a hotspot so that the user may click to navigate to that corner. I have completed the code to get the house to spin to the correct hotspot when the user clicks on a hotspot but where I'm struggling is working out the correct code so that if you are on position 1 and...
0
8969
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8788
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9335
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.