473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

a2k - weird code behaviour I can't explain...

Here's the code;
Private Sub txtTeachName_Lo stFocus()

If IsNull(Me.txtNa me) Then 'line A
Forms!frmMainfo rm!frmSubform.L ocked = True
GoTo Exit_txtName
Else 'line B
Forms!frmMainfo rm!frmSubform.L ocked = False 'line C
If IsEmpty(oldName ) Then
oldName = Me.Name
GoTo Exit_txtName
End If
End If

Exit_txtName:
Exit Sub

End Sub
If txtName isn't a null then I see the code jump to Else (the line marked B)
and then jump back to the first If - i.e it doesn't run the code after the
Else statement.
This happens around 25 times then finally the pointer moves on and finally
reaches the Exit Sub at the end.
However it does NOT exit the code as I would expect but instead moves to the
line marked C. It then moves to A. This second loop keeps going for quite
a while and I'm still stepping through it as I write.

I really have no idea why this is happening - I can only assume it's caused
by some weird combination of events, yet I am stepping through everything
and only the lostfocus event is firing.
Any ideas?

thanks
Martin
Nov 12 '05 #1
8 1427
How many lines on your subform?
"Deano" <de*********@ho tmail.com> wrote in message
news:Hn******** ********@wards. force9.net...
Here's the code;
Private Sub txtTeachName_Lo stFocus()

If IsNull(Me.txtNa me) Then 'line A
Forms!frmMainfo rm!frmSubform.L ocked = True
GoTo Exit_txtName
Else 'line B
Forms!frmMainfo rm!frmSubform.L ocked = False 'line C
If IsEmpty(oldName ) Then
oldName = Me.Name
GoTo Exit_txtName
End If
End If

Exit_txtName:
Exit Sub

End Sub
If txtName isn't a null then I see the code jump to Else (the line marked B) and then jump back to the first If - i.e it doesn't run the code after the
Else statement.
This happens around 25 times then finally the pointer moves on and finally
reaches the Exit Sub at the end.
However it does NOT exit the code as I would expect but instead moves to the line marked C. It then moves to A. This second loop keeps going for quite a while and I'm still stepping through it as I write.

I really have no idea why this is happening - I can only assume it's caused by some weird combination of events, yet I am stepping through everything
and only the lostfocus event is firing.
Any ideas?

thanks
Martin

Nov 12 '05 #2
Phil Stanton wrote:
How many lines on your subform?
46 filtered records.


"Deano" <de*********@ho tmail.com> wrote in message
news:Hn******** ********@wards. force9.net...
Here's the code;
Private Sub txtTeachName_Lo stFocus()

If IsNull(Me.txtNa me) Then 'line A
Forms!frmMainfo rm!frmSubform.L ocked = True
GoTo Exit_txtName
Else 'line B
Forms!frmMainfo rm!frmSubform.L ocked = False 'line C
If IsEmpty(oldName ) Then
oldName = Me.Name
GoTo Exit_txtName
End If
End If

Exit_txtName:
Exit Sub

End Sub
If txtName isn't a null then I see the code jump to Else (the line
marked B) and then jump back to the first If - i.e it doesn't run
the code after the Else statement.
This happens around 25 times then finally the pointer moves on and
finally reaches the Exit Sub at the end.
However it does NOT exit the code as I would expect but instead
moves to the line marked C. It then moves to A. This second loop
keeps going for quite a while and I'm still stepping through it as I
write.

I really have no idea why this is happening - I can only assume it's
caused by some weird combination of events, yet I am stepping
through everything and only the lostfocus event is firing.
Any ideas?

thanks
Martin


Nov 12 '05 #3
Can't help then I was wondering if it was requerying the subform once for
each record, but no

Sorry

"Deano" <de*********@ho tmail.com> wrote in message
news:EV******** *********@wards .force9.net...
Phil Stanton wrote:
How many lines on your subform?


46 filtered records.


"Deano" <de*********@ho tmail.com> wrote in message
news:Hn******** ********@wards. force9.net...
Here's the code;
Private Sub txtTeachName_Lo stFocus()

If IsNull(Me.txtNa me) Then 'line A
Forms!frmMainfo rm!frmSubform.L ocked = True
GoTo Exit_txtName
Else 'line B
Forms!frmMainfo rm!frmSubform.L ocked = False 'line C
If IsEmpty(oldName ) Then
oldName = Me.Name
GoTo Exit_txtName
End If
End If

Exit_txtName:
Exit Sub

End Sub
If txtName isn't a null then I see the code jump to Else (the line
marked B) and then jump back to the first If - i.e it doesn't run
the code after the Else statement.
This happens around 25 times then finally the pointer moves on and
finally reaches the Exit Sub at the end.
However it does NOT exit the code as I would expect but instead
moves to the line marked C. It then moves to A. This second loop
keeps going for quite a while and I'm still stepping through it as I
write.

I really have no idea why this is happening - I can only assume it's
caused by some weird combination of events, yet I am stepping
through everything and only the lostfocus event is firing.
Any ideas?

thanks
Martin


Nov 12 '05 #4
Phil Stanton wrote:
Can't help then I was wondering if it was requerying the subform once
for each record, but no

Sorry
Thanks anyhow, i think i'm going to have to live with it until inspiration
strikes. It doesn't do any harm but i am wondering why it's happening. Or
if it only happens when I debug line by line, which would be ironic....

"Deano" <de*********@ho tmail.com> wrote in message
news:EV******** *********@wards .force9.net...
Phil Stanton wrote:
How many lines on your subform?


46 filtered records.


"Deano" <de*********@ho tmail.com> wrote in message
news:Hn******** ********@wards. force9.net...
Here's the code;
Private Sub txtTeachName_Lo stFocus()

If IsNull(Me.txtNa me) Then 'line A
Forms!frmMainfo rm!frmSubform.L ocked = True
GoTo Exit_txtName
Else 'line B
Forms!frmMainfo rm!frmSubform.L ocked = False 'line C
If IsEmpty(oldName ) Then
oldName = Me.Name
GoTo Exit_txtName
End If
End If

Exit_txtName:
Exit Sub

End Sub
If txtName isn't a null then I see the code jump to Else (the line
marked B) and then jump back to the first If - i.e it doesn't run
the code after the Else statement.
This happens around 25 times then finally the pointer moves on and
finally reaches the Exit Sub at the end.
However it does NOT exit the code as I would expect but instead
moves to the line marked C. It then moves to A. This second loop
keeps going for quite a while and I'm still stepping through it as
I write.

I really have no idea why this is happening - I can only assume
it's caused by some weird combination of events, yet I am stepping
through everything and only the lostfocus event is firing.
Any ideas?

thanks
Martin


Nov 12 '05 #5
de*********@hot mail.com (Deano) wrote in
<Hn************ ****@wards.forc e9.net>:
Here's the code;

Private Sub txtTeachName_Lo stFocus()

If IsNull(Me.txtNa me) Then 'line A
Forms!frmMainfo rm!frmSubform.L ocked = True
GoTo Exit_txtName
Else 'line B
Forms!frmMainfo rm!frmSubform.L ocked = False 'line C
If IsEmpty(oldName ) Then
oldName = Me.Name
GoTo Exit_txtName
End If
End If

Exit_txtName :
Exit Sub

End Sub
Here's code that does the same thing:

Forms!frmMainfo rm!frmSubform.L ocked = IsNull(Me!txtNa me)
If (Forms!frmMainf orm!frmSubform. Locked) _
And IsEmpty(oldName ) Then
oldName = Me.Name
End If

Now, I don't know what "oldName" refers to, but I assume it is a
form-level or public variable. I don't know why you're testing it
for "IsEmpty," which I only know about using with variants, and
even then, it's not entirely reliable.

If you're storing a string (the name of a form), then the variable
ought to be a string variable. And you'd test it with:

Len(strOldName) =0

So, your code seems vastly more complicated than it needs to be.
If txtName isn't a null then I see the code jump to Else (the line
marked B) and then jump back to the first If - i.e it doesn't run
the code after the Else statement.
Then that means that txtName is never Null. Does the field it's
bound to allow zero-length strings? If so, then it may very well be
"empty" from a human point of view and still not be Null.
This happens around 25 times then finally the pointer moves on and
finally reaches the Exit Sub at the end.
However it does NOT exit the code as I would expect but instead
moves to the line marked C. It then moves to A. This second loop
keeps going for quite a while and I'm still stepping through it as
I write.
I don't quite understand the relationships of the form. Is the form
referred to by Me the subform you're trying to lock? If so, then
you really can't do this from the subform.

I also question why you're using the LostFocus event, and not the
AfterUpdate event. I'm not certain, but there may be circumstances
where a control, loses focuses but does not fire the update events
(such as when the form the control is a part of loses focus), so
you could be testing for Null before it actually *is* Null.
I really have no idea why this is happening - I can only assume
it's caused by some weird combination of events, yet I am stepping
through everything and only the lostfocus event is firing.


I don't know what you are trying to accomplish.

Please explain what your code is doing and why, and then maybe we
can diagnose it.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #6
David W. Fenton wrote:
de*********@hot mail.com (Deano) wrote in
<Hn************ ****@wards.forc e9.net>:

<snipped>

Thanks for the tips David.

At the moment it *is* working OK but I'm so busy looking at other things I'm
not going to have time to take this further (maybe later). The issue with
the oldname variable etc is to be able to know when the name's been changed
and the control in question is on the main form. It's a validation thing
and was done many months ago. Knowing what I know now I think it could be
done alot better.

What I was hoping that this was some fundamental Access glitch or well-known
behaviour that was easy to rectify....
Nov 12 '05 #7
de*********@hot mail.com (Deano) wrote in
<OD************ *****@wards.for ce9.net>:
David W. Fenton wrote:
de*********@hot mail.com (Deano) wrote in
<Hn************ ****@wards.forc e9.net>:

<snipped>

Thanks for the tips David.

At the moment it *is* working OK but I'm so busy looking at other
things I'm not going to have time to take this further (maybe
later). The issue with the oldname variable etc is to be able to
know when the name's been changed and the control in question is
on the main form. It's a validation thing and was done many
months ago. Knowing what I know now I think it could be done alot
better.

What I was hoping that this was some fundamental Access glitch or
well-known behaviour that was easy to rectify....


I still don't know what your problem could be because I don't knoiw
the context in which the code is running.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 12 '05 #8
David W. Fenton wrote:
de*********@hot mail.com (Deano) wrote in
<OD************ *****@wards.for ce9.net>:
David W. Fenton wrote:
de*********@hot mail.com (Deano) wrote in
<Hn************ ****@wards.forc e9.net>:

<snipped>

Thanks for the tips David.

At the moment it *is* working OK but I'm so busy looking at other
things I'm not going to have time to take this further (maybe
later). The issue with the oldname variable etc is to be able to
know when the name's been changed and the control in question is
on the main form. It's a validation thing and was done many
months ago. Knowing what I know now I think it could be done alot
better.

What I was hoping that this was some fundamental Access glitch or
well-known behaviour that was easy to rectify....


I still don't know what your problem could be because I don't knoiw
the context in which the code is running.


It's OK, i'm content to drop it for the time being. At the moment I'm not
keen on revisiting code unless i have to since it means i have to work out
what it all meant in the first place. My initial post was tangential to
something else but now that is cleared up so I will leave it for the time
being.

I do however think it is an interesting problem that might be of interest to
others and will post back on this subject when time permits and I can supply
the correct level of detail.
Nov 12 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
1745
by: Sylvain Thenault | last post by:
Hi there ! Can someone explain me the following behaviour ? >>> l = >>> 0 in (l is False) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: iterable argument required >>> (0 in l) is False
3
1583
by: Philip Yale | last post by:
I'm very puzzled by the choice of NC index being made by the optimizer in this example. I don't actually think it should use an NC index at all. I have: Table: CustomerStatus_T Single data page 19 records Clustered Index on CustomerStatusID:
7
5376
by: Jon Combe | last post by:
I have created the following test SQL code to illustrate a real problem I have with some SQL code. CREATE TABLE JCTable ( CustomerName varchar(50) ) ALTER TABLE JCTable ADD CustomerNo int INSERT INTO JCTable ( CustomerName , CustomerNo ) VALUES ( 'Jon Combe' , 1 ) INSERT INTO JCTable ( CustomerName , CustomerNo ) VALUES ( 'Bill Gates' , 1...
8
5731
by: Hostile17 | last post by:
Consider the following HTML. ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <title>Untitled</title>
10
2041
by: Chris Mantoulidis | last post by:
I see some really weird output from this program (compiled with GCC 3.3.2 under Linux). #include <iostream> using namespace std; int main() { char *s; s = "test1"; cout << "s = " << s << " and &s = " << &s << "\n";
1
1284
by: Pankaj | last post by:
Hi All, I use a Hashtable in my program to keep unique items...at one instance I need to repopulate this hashtable through a loop. when starting repopulation hashtable.count() returns ZERO hence first item gets added successfully but as soon as the control reaches top of foreach loop somehow a second item which indeed existed before...
8
1533
by: Daniel Yelland | last post by:
Hi, I have developed a number of code libraries in Win32 DLLs and have written a number of test suite executables that implicitly link to these libraries in order to test them. In one of my test applications, which runs fine in Debug mode, it is crashing in the destructor of a local object on the stack when it is built in release mode. ...
38
2680
by: baong | last post by:
dear all i have use this line to time in many my web base appl. but now i found a weird problem the javascript line is the same but i use the calculation 2 time @ the first time, it is ok, 3 * 31.9 = 95.7 @ the second time, 3 * 31.9 = 95.69999999999999 this is the list number which calculation is NOT correct 6 * 31.9 = 191.39999999999998 7
41
2491
by: Petr Jakes | last post by:
Hello, I am trying to study/understand OOP principles using Python. I have found following code http://tinyurl.com/a4zkn about FSM (finite state machine) on this list, which looks quite useful for my purposes. As this code was posted long time ago (November 1998) I would like to ask if the principles used in this code are still valid in the...
0
7411
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...
0
7669
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7926
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...
1
7439
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5987
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...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4962
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...
0
3468
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...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.