473,773 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange report error message - control must have focus

I have a report which prints data from a parent table and two child
tables (Contract and Kosten). Because it is a bit long, I suppress some
fields which are often empty, based on methods found in the archive for
this group: allowing can-shrink on the field itself and the following
code in the details section to suppress the label:

If (Me!InpassingWe rkproces.Text = "") Then
Me!InpassingWer kproces_Bijschr ift.Visible = False
Else
Me!InpassingWer kproces_Bijschr ift.Visible = True
End If

The suppressed fields occur in all three records.

When there is both a Contract and Kosten record this works fine. If
there is no Kosten record this works fine. But when there is no Contract
record I get an error message (translated from the Dutch) "you can only
refer to a property or method of a control if the control has the
focus". On debugging, the code complained about is the 'if' line of the
first instance of the label-suppression code above. If I comment that
out, it complains about the next instance.

I have looked in vain for differences in the ways I handle Contract and
Kosten records.

Can anyone suggest where I should be looking?
(Access 2000, Dutch version, Windows XP Pro)

========

Subsidiary question (much less important): the examples I found in the
archive all provided only the first half of the above IF statement. But
I found that the value of the 'Visible' property was maintained from one
detail record to the next: once I set it to False, it remained False for
all subsequent records. Has the behaviour of Access changed at some
point?

--
Stephen Poley
Nov 13 '05 #1
12 2067
On Sun, 30 Oct 2005 07:44:13 +0100, Stephen Poley <sb************ ******@xs4all.n l> wrote:
I have a report which prints data from a parent table and two child
tables (Contract and Kosten). Because it is a bit long, I suppress some
fields which are often empty, based on methods found in the archive for
this group: allowing can-shrink on the field itself and the following
code in the details section to suppress the label:

If (Me!InpassingWe rkproces.Text = "") Then
Me!InpassingWer kproces_Bijschr ift.Visible = False
Else
Me!InpassingWer kproces_Bijschr ift.Visible = True
End If

The suppressed fields occur in all three records.

When there is both a Contract and Kosten record this works fine. If
there is no Kosten record this works fine. But when there is no Contract
record I get an error message (translated from the Dutch) "you can only
refer to a property or method of a control if the control has the
focus". On debugging, the code complained about is the 'if' line of the
first instance of the label-suppression code above. If I comment that
out, it complains about the next instance.

I have looked in vain for differences in the ways I handle Contract and
Kosten records.

Can anyone suggest where I should be looking?
(Access 2000, Dutch version, Windows XP Pro)

========

Subsidiary question (much less important): the examples I found in the
archive all provided only the first half of the above IF statement. But
I found that the value of the 'Visible' property was maintained from one
detail record to the next: once I set it to False, it remained False for
all subsequent records. Has the behaviour of Access changed at some
point?

Use -
If (Me!InpassingWe rkproces= "")
instead of
If (Me!InpassingWe rkproces.Text = "")

The Text property is only available if the control has focus, which never happens in a report.

Nov 13 '05 #2
On Sun, 30 Oct 2005 08:18:50 GMT, Wayne Gillespie
<be*****@NOhotm ailSPAM.com.au> wrote:
On Sun, 30 Oct 2005 07:44:13 +0100, Stephen Poley <sb************ ******@xs4all.n l> wrote:
I have a report which prints data from a parent table and two child
tables (Contract and Kosten). Because it is a bit long, I suppress some
fields which are often empty: <snip> If (Me!InpassingWe rkproces.Text = "") Then
Me!InpassingWer kproces_Bijschr ift.Visible = False
Else
Me!InpassingWer kproces_Bijschr ift.Visible = True
End If

The suppressed fields occur in all three records.

When there is both a Contract and Kosten record this works fine. If
there is no Kosten record this works fine. But when there is no Contract
record I get an error message (translated from the Dutch) "you can only
refer to a property or method of a control if the control has the
focus".
Use -
If (Me!InpassingWe rkproces= "")
instead of
If (Me!InpassingWe rkproces.Text = "")

The Text property is only available if the control has focus, which never happens in a report.

If that is the case, how is it that my report works fine when both child
records are present?

--
Stephen Poley
Nov 13 '05 #3
1. Try using the .Value property instead of .Text.
Or just use
If (Me!InpassingWe rkproces = "") Then

2. The behavior you've observed (changing the formatting of a detail record
remains until changed again) has been there as long as I've been working
with Access (back to 2.0).

HTH

"Stephen Poley" <sb************ ******@xs4all.n l> wrote in message
news:e2******** *************** *********@4ax.c om...
I have a report which prints data from a parent table and two child
tables (Contract and Kosten). Because it is a bit long, I suppress some
fields which are often empty, based on methods found in the archive for
this group: allowing can-shrink on the field itself and the following
code in the details section to suppress the label:

If (Me!InpassingWe rkproces.Text = "") Then
Me!InpassingWer kproces_Bijschr ift.Visible = False
Else
Me!InpassingWer kproces_Bijschr ift.Visible = True
End If

The suppressed fields occur in all three records.

When there is both a Contract and Kosten record this works fine. If
there is no Kosten record this works fine. But when there is no Contract
record I get an error message (translated from the Dutch) "you can only
refer to a property or method of a control if the control has the
focus". On debugging, the code complained about is the 'if' line of the
first instance of the label-suppression code above. If I comment that
out, it complains about the next instance.

I have looked in vain for differences in the ways I handle Contract and
Kosten records.

Can anyone suggest where I should be looking?
(Access 2000, Dutch version, Windows XP Pro)

========

Subsidiary question (much less important): the examples I found in the
archive all provided only the first half of the above IF statement. But
I found that the value of the 'Visible' property was maintained from one
detail record to the next: once I set it to False, it remained False for
all subsequent records. Has the behaviour of Access changed at some
point?

--
Stephen Poley

Nov 13 '05 #4
Wayne Gillespie wrote:
Use -
If (Me!InpassingWe rkproces= "")
instead of
If (Me!InpassingWe rkproces.Text = "")

The Text property is only available if the control has focus...


I've noticed this too and have been puzzled by it. Isn't Text the
default property of a TextBox?

So other than the fact that one way works and the other does not, what
is the difference between these two statements?

txtMyText = "foo"
txtMyText.Text = "bar"

Is this some peculiarity of Access VBA?

--
Smartin
Nov 13 '05 #5
Smartin <sm********@yah oo.com> wrote in
news:w9******** ************@gi ganews.com:
Wayne Gillespie wrote:
Use -
If (Me!InpassingWe rkproces= "")
instead of
If (Me!InpassingWe rkproces.Text = "")

The Text property is only available if the control has
focus...
I've noticed this too and have been puzzled by it. Isn't Text
the default property of a TextBox?


The default value of any control that can be bound to a field is
..value. At least the rule is consistent.

The .text property contains whatever the user has typed into a
control, for editing. since it can only be edited when the
control has focus, the property is only accessible when the
control has focus.
So other than the fact that one way works and the other does
not, what is the difference between these two statements?

txtMyText = "foo"
txtMyText.Text = "bar"
txtMyText refers to the bound value,
as does txtmytext = 99

txtMyText.Text = "bar" refers to the value of txtMytext while
the field is being edited.

The use of the two properties allows one to cancel an edit, ir
to save it.
Is this some peculiarity of Access VBA?

Probably, as it's only necessary when editing a bound control.
--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #6
Smartin wrote:
Wayne Gillespie wrote:
Use -
If (Me!InpassingWe rkproces= "")
instead of
If (Me!InpassingWe rkproces.Text = "")

The Text property is only available if the control has focus...
I've noticed this too and have been puzzled by it. Isn't Text the
default property of a TextBox?


In VB yes. In Access the Value property is the default.
So other than the fact that one way works and the other does not, what
is the difference between these two statements?

txtMyText = "foo"
txtMyText.Text = "bar"

Is this some peculiarity of Access VBA?


The Text property in Access is the not yet committed text in the control as you
are editing it. That is why it is only available for the control that currently
has focus.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 13 '05 #7
Thanks for the explanation
--
Smartin
Nov 13 '05 #8
Thank you for the explanation.
--
Smartin
Nov 13 '05 #9
On Sun, 30 Oct 2005 22:31:14 GMT, "MacDermott " <ma********@nos pam.com>
wrote:
1. Try using the .Value property instead of .Text.
Or just use
If (Me!InpassingWe rkproces = "") Then
That's actually what I started with, but it didn't work.
IsNull(Me!Inpas singWerkproces) turned out to work. See my other post.
2. The behavior you've observed (changing the formatting of a detail record
remains until changed again) has been there as long as I've been working
with Access (back to 2.0).


OK, thanks. Apparently some of the code posted here that I thought was
real code must have just been air code.

--
Stephen Poley
Nov 13 '05 #10

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

Similar topics

6
1798
by: WindAndWaves | last post by:
Hi Gurus The page below has a strange error. It seems to be working very well, just when you enter 8 or 9 for day, month or year then you get an error. I really have no idea where that is coming from. Can you help? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD>
3
6417
by: Lore Leuneog | last post by:
Hello Which command do I've to use to set the focus on a control placed on a report in Design-View. Ctrl.SetFocus and Cmd.GoToControl don't work for a report. The aim is to copy the control from the report into memory using the DoCmd.RunCommand command. (Access 2000) Thank you
1
2660
by: intl04 | last post by:
I am getting strange print-related error messages when trying to create (not print!) reports. For example, when I click 'new' to create a report then choose 'design view', I get an error message that says: 'There was a problem retrieving printer information for this object. The object may have been sent to a printer that was unavailable.' When I choose 'report wizard', I can go through all of the steps but then I get an error message...
9
3076
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want to appear in the report is Yes, No, or Maybe. What do I need to do to change what appears in the report/what term do I need to search out in Google? Thank you Colin
1
2062
by: clickon | last post by:
For testing purposes i have got a 2 step WizardControl. Eqach step contains a text box, TextBox1 and TextBox2 respectively. If i put the following code in the respective activate event handlers for the two steps, TextBox1.Text ="foo"; and TextBox2.Text = "bar";
7
1447
by: ChrisM | last post by:
I posted this last week, so apologies for re-posting but I'm still looking for a sensible answer, and I'm hoping somone new might be able to cast some light... Basically, I have a fairly complicated application which seems to me to be misbehaving. The following is an attempt to reproduce the error. There are reasons in the real application why I'm trying to do things the way they are here, so please no comments on techniques here,...
7
1562
by: saurabh | last post by:
Hey, I have a form in which there are say 10 fields. I am using validator control for all the fields. suppose user forgets to fill field no. 5, 8 , 9 and 10. So on clicking the save button,obviously an error willl be raised. Is there anyway such that when the error is raised the focus goes to first control that has false validation (e.g in our case that control is 5) ? Right now after clicking the save button, none of the control has...
5
3110
by: Ian | last post by:
Hi everyone, I have found some bizarre (to me...!) behaviour of the Form_Activate function. I have a form which has a button control used to close the form and a subform with a datasheet view showing a list of jobs from the database. When the main form loses focus and the user clicks the 'Close' button, I kept receiving error 2585 (This action cannot be carried out whilst processing a form or report event). This was tracked down to...
3
1348
salimudheen
by: salimudheen | last post by:
While i try to open the report from my system is okey. But in network system it displays the error message "You can't disable a control while it has focus". But actually i never focus any control. Then y this happened....
0
9621
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
9454
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
10264
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8937
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...
1
7461
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6716
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
5355
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
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.