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

Run-time error 2424 is driving me mad

The current event of a continuous form is:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub

This works fine. The form has a bound control QuoteNumber with its
control source as QuoteNumber. This is a text field.

However I wish to extend this and disable another button if the
QuoteNumber has a particular value:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
If Me.QuoteNumber = "Regret" Then
Me.RegretButton.Enabled = false
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End if
End sub

As soon as I do this I get:
Run-time error 2424
The expression you entered has a field, control, property name that
Microsoft Access can't find.

So I simplified it to:
Private Sub Form_Current()
Debug.print Me.QuoteNumber
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub
but this gives the same error. In the working version at the top I can
step through with the debugger and see that Me.QuoteNumber has correct
values, either null or some text but as soon as I try to use the value
of the control/field in some other way things go pear shaped.

Why is it that when I try to do anything else with it, I get an error?

I have replaced the . by !, decompiled, compacted and even deleted the
form and imported a fresh copy from another database but to no avail.
I must have done something similar a thousand times without problem but
something odd seems to be happening here.

Any guesses would be welcome.

Jim

Oct 14 '06 #1
3 16617
>I can step through with the debugger and see that Me.QuoteNumber has
>correct values, either null or some text but as soon as I try to use
the value of the control/field in some other way things go pear
shaped.

Why is it that when I try to do anything else with it, I get an
error?
Sometimes things can get confusing to Access when...

1. The developer relies on the default property of an object. In some
contexts Access can get annoyed if you refer to just the object name
(Me.QuoteNumber) when you really mean its default property
(Me.QuoteNumber.Value).

....and/or...

2. A control on the form/report has the same name as a field in the
underlying recordset. Unfortunately, this is the case when you drag a
field from the field list and drop it onto the form/report. Sometimes
just changing the name of the control from "QuoteNumber" to
"txtQuoteNumber" can clear things up.
Jim Devenish wrote:
The current event of a continuous form is:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub

This works fine. The form has a bound control QuoteNumber with its
control source as QuoteNumber. This is a text field.

However I wish to extend this and disable another button if the
QuoteNumber has a particular value:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
If Me.QuoteNumber = "Regret" Then
Me.RegretButton.Enabled = false
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End if
End sub

As soon as I do this I get:
Run-time error 2424
The expression you entered has a field, control, property name that
Microsoft Access can't find.

So I simplified it to:
Private Sub Form_Current()
Debug.print Me.QuoteNumber
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub
but this gives the same error. In the working version at the top I can
step through with the debugger and see that Me.QuoteNumber has correct
values, either null or some text but as soon as I try to use the value
of the control/field in some other way things go pear shaped.

Why is it that when I try to do anything else with it, I get an error?

I have replaced the . by !, decompiled, compacted and even deleted the
form and imported a fresh copy from another database but to no avail.
I must have done something similar a thousand times without problem but
something odd seems to be happening here.

Any guesses would be welcome.

Jim
Oct 14 '06 #2
Hi Jim

Perhaps a control name is not the same as the field name?

Here's an alternative to try. Using the With construct should prevent if
from barfing half way through, and might help identify where the problem
really lies. Just as importantly, the buttons' Caption/Enabled properties
are set for all cases: that gets really messy to maintain when you have
nested If blocks. As a minor issue, it sets the values only if they need
changing (since setting is much slower than testing.) HTH:

Private Sub Form_Current()
Dim bDisable As Boolean
Dim strCaption As String

With Me.QuoteNumber
If IsNull(.Value) Then
strCaption = "Create quote letter"
Else
strCaption = "View quote letter"
If .Value = "Regret" Then
bDisable = True
End If
End If
End With

With Me.RegretButton
If .Enabled = bDisable Then
.Enabled = Not bDisable
End If
End With

With Me.quoteLetterButton
If .Caption <strCaption Then
.Caption = strCaption
End If
End With
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Jim Devenish" <in***************@foobox.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
The current event of a continuous form is:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub

This works fine. The form has a bound control QuoteNumber with its
control source as QuoteNumber. This is a text field.

However I wish to extend this and disable another button if the
QuoteNumber has a particular value:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
If Me.QuoteNumber = "Regret" Then
Me.RegretButton.Enabled = false
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End if
End sub

As soon as I do this I get:
Run-time error 2424
The expression you entered has a field, control, property name that
Microsoft Access can't find.

So I simplified it to:
Private Sub Form_Current()
Debug.print Me.QuoteNumber
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub
but this gives the same error. In the working version at the top I can
step through with the debugger and see that Me.QuoteNumber has correct
values, either null or some text but as soon as I try to use the value
of the control/field in some other way things go pear shaped.

Why is it that when I try to do anything else with it, I get an error?

I have replaced the . by !, decompiled, compacted and even deleted the
form and imported a fresh copy from another database but to no avail.
I must have done something similar a thousand times without problem but
something odd seems to be happening here.

Any guesses would be welcome.

Jim

Oct 14 '06 #3
Thank you both for your help. Sadly nothing worked. So I started this
one again and designed a new form to replace this and got it to do just
what I wanted in much the way I had originally intended.

I guess that the first form got itself in a mess and nothing would sort
it out. I will leave as one of life's little mysteries.

JIM
Allen Browne wrote:
Hi Jim

Perhaps a control name is not the same as the field name?

Here's an alternative to try. Using the With construct should prevent if
from barfing half way through, and might help identify where the problem
really lies. Just as importantly, the buttons' Caption/Enabled properties
are set for all cases: that gets really messy to maintain when you have
nested If blocks. As a minor issue, it sets the values only if they need
changing (since setting is much slower than testing.) HTH:

Private Sub Form_Current()
Dim bDisable As Boolean
Dim strCaption As String

With Me.QuoteNumber
If IsNull(.Value) Then
strCaption = "Create quote letter"
Else
strCaption = "View quote letter"
If .Value = "Regret" Then
bDisable = True
End If
End If
End With

With Me.RegretButton
If .Enabled = bDisable Then
.Enabled = Not bDisable
End If
End With

With Me.quoteLetterButton
If .Caption <strCaption Then
.Caption = strCaption
End If
End With
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Jim Devenish" <in***************@foobox.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
The current event of a continuous form is:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub

This works fine. The form has a bound control QuoteNumber with its
control source as QuoteNumber. This is a text field.

However I wish to extend this and disable another button if the
QuoteNumber has a particular value:
Private Sub Form_Current()
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
If Me.QuoteNumber = "Regret" Then
Me.RegretButton.Enabled = false
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End if
End sub

As soon as I do this I get:
Run-time error 2424
The expression you entered has a field, control, property name that
Microsoft Access can't find.

So I simplified it to:
Private Sub Form_Current()
Debug.print Me.QuoteNumber
If IsNull(me.QuoteNumber) Then
Me.quoteLetterButton.Caption = "Create quote letter"
Else
Me.quoteLetterButton.Caption = "View quote letter"
End if
End sub
but this gives the same error. In the working version at the top I can
step through with the debugger and see that Me.QuoteNumber has correct
values, either null or some text but as soon as I try to use the value
of the control/field in some other way things go pear shaped.

Why is it that when I try to do anything else with it, I get an error?

I have replaced the . by !, decompiled, compacted and even deleted the
form and imported a fresh copy from another database but to no avail.
I must have done something similar a thousand times without problem but
something odd seems to be happening here.

Any guesses would be welcome.

Jim
Oct 14 '06 #4

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

Similar topics

3
by: leroybt.rm | last post by:
Can someone tell me how to run a script from a interactive shell I type the following: >>>python filename >>>python filename.py >>>run filename >>>run filename.py >>>/run filename >>>/run...
4
by: Ed | last post by:
Hello, I took a course in asp about 2 years ago and I was practicing with IIS 5.0. Then I put it down for a while. Now trying to get back to it. I can't run asp files from subdirectories of...
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
19
by: Bryan | last post by:
How can i run a bit of code straight from the IDE? Right now i make a temporary button and put the code behind that, then i run debug mode and click on the button. Is there a way to highlight...
9
by: Brett Wesoloski | last post by:
I am new to VS2005. I changed my program.cs file to be a different form I am working on. But when I go to run the application it still brings up the form that was originally declared as new. ...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
8
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? --...
3
by: traceable1 | last post by:
Is there a way I can set up a SQL script to run when the instance starts up? SQL Server 2005 SP2 thanks!
7
by: mxdevit | last post by:
Task: run application from ASP.NET for example, you have a button on ASP.NET page, when press this button - one application is invoked. the code to run application (for example, notepad) is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.