473,788 Members | 2,854 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
12 2068
On Mon, 31 Oct 2005 00:25:28 GMT, Bob Quintal <rq******@sympa tico.ca>
wrote:
Smartin <sm********@yah oo.com> wrote in
news:w9******* *************@g iganews.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.


OK, I've tried various possibilities out, in the hope that it gives
useful information to future browsers of the archive. The following
works, i.e. it suppresses labels for empty fields in my report:

If IsNull(Me!Extra Info) Then
Me!ExtraInfo_Bi jschrift.Visibl e = False
Else
Me!ExtraInfo_Bi jschrift.Visibl e = True
End If

Using IsNull(Me!Extra Info.Value) also works.

(Me!ExtraInfo = "") and (Me!ExtraInfo.V alue = "") do not work for me. I
don't know whether one can get a zero-length string in an Access field -
I don't seem to have them, anyway.

(Me!ExtraInfo.T ext = "") should not work at all in reports according to
you and Rick, yet sometimes it does - see my original post. But, as I
discovered, it's not reliable and presumably should be avoided in
reports.

I would hazard a guess that at some stage someone at Microsoft thought
it would be handy to provide Text as a synonym to Value in reports, for
people who are used to VB. But if so, the idea was never carried through
consistently (and it seems a pretty bad idea to me anyway).

--
Stephen Poley
Nov 13 '05 #11
On Mon, 31 Oct 2005 19:51:20 +0100, Stephen Poley <sb************ ******@xs4all.n l> wrote:

OK, I've tried various possibilities out, in the hope that it gives
useful information to future browsers of the archive. The following
works, i.e. it suppresses labels for empty fields in my report:

If IsNull(Me!Extra Info) Then
Me!ExtraInfo_Bi jschrift.Visibl e = False
Else
Me!ExtraInfo_Bi jschrift.Visibl e = True
End If

Using IsNull(Me!Extra Info.Value) also works.

(Me!ExtraInf o = "") and (Me!ExtraInfo.V alue = "") do not work for me. I
don't know whether one can get a zero-length string in an Access field -
I don't seem to have them, anyway.

(Me!ExtraInfo. Text = "") should not work at all in reports according to
you and Rick, yet sometimes it does - see my original post. But, as I
discovered, it's not reliable and presumably should be avoided in
reports.

I would hazard a guess that at some stage someone at Microsoft thought
it would be handy to provide Text as a synonym to Value in reports, for
people who are used to VB. But if so, the idea was never carried through
consistently (and it seems a pretty bad idea to me anyway).


You can also test for Nulls and Zero-Length Strings together by using -

If Len(Me!ExtraInf o & vbNullString)=0

This is handy if the Allow Zero Length String property of the table is set to Yes, and the table could contain a mix of
either Nulls or ZLS's.

Nov 13 '05 #12
On Tue, 01 Nov 2005 02:59:42 GMT, Wayne Gillespie
<be*****@NOhotm ailSPAM.com.au> wrote:

You can also test for Nulls and Zero-Length Strings together by using -

If Len(Me!ExtraInf o & vbNullString)=0

This is handy if the Allow Zero Length String property of the table is set to Yes, and the table could contain a mix of
either Nulls or ZLS's.


Thanks.

--
Stephen Poley
Nov 13 '05 #13

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

Similar topics

6
1799
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
3077
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
2063
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
9656
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
9498
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
10364
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...
1
10110
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
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
8993
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
6750
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
5398
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
5536
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.