Error 2424

G

Guest

In sub Form_Current, I am getting a 2424 Error "The expression you entered
has a field, control, or property name that ... can't find.

I have a field named fmFormNo on the form. The form displays with the
"#Name" error showing. This field is not locked.

The error line in VB is: If fmFormNo <> nTemp then (when nTemp is an integer)

The next line after the end if is: fmFormName = GetFormName(), which does
not cause any problems.

The funny thing is that when the cursor is placed over fmFormNo, it shows a
1 (the same as for nTemp).

Thanks,
John H W
 
D

Dirk Goldgar

John H W said:
In sub Form_Current, I am getting a 2424 Error "The expression you
entered has a field, control, or property name that ... can't find.

I have a field named fmFormNo on the form. The form displays with the
"#Name" error showing. This field is not locked.

The error line in VB is: If fmFormNo <> nTemp then (when nTemp is an
integer)

The next line after the end if is: fmFormName = GetFormName(), which
does not cause any problems.

The funny thing is that when the cursor is placed over fmFormNo, it
shows a 1 (the same as for nTemp).

Thanks,
John H W

What is in the ControlSource property of the control named "fmFormNo"?
 
G

Guest

What is in the ControlSource property of the control named "fmFormNo"?
InvFormNo - which is the name of the field in the table.

I have another form whlch is called from the main form (as is the Inventory
Form) and it works perfectly. I have checked to make sure that there are no
other table fields or boxes on any form which is named the same.

Thanks for your help.

John H W
 
D

Dirk Goldgar

This seems odd, considering that you say hovering over the control name
in the VB Editor displays a valid value.

1. Is the recordsource of the form a query, or the table itself? If
it's a query, what is the SQL of the query?

2. Is there conditional formatting applied to the "fmFormNo" control?
If so, what is it?

3. Is there another control bound to the field InvFormNo on the form?
 
G

Guest

With all of my "trial and error" checking, I no longer get the value
displayed when hovering. If I type in the Form_Inventory. - I get the box
listed in the pop-up box. Even when I select the box, I still get the error.

Answers:

1. Table itself.
2. No conditional formatting (that I put in).
3. No other control is bound to this box.

Thanks, John H W
 
D

Dirk Goldgar

John H W said:
With all of my "trial and error" checking, I no longer get the value
displayed when hovering. If I type in the Form_Inventory. - I get
the box listed in the pop-up box. Even when I select the box, I still
get the error.

I don't understand what you mean by that last sentence. Could you
expand on that a bit?

In an earlier message, you said:
I have another form whlch is called from the main form (as is the Inventory
Form) and it works perfectly.

When you refer to a "main form", are you saying that the problem form is
a subform that appears on the main form, or are you just speaking of the
logical relationship of the forms?
 
G

Guest

Logical I have a "main" form which has the particulars of the form. One this
form I have two command buttons which each opens a different form (one for
"copies made" and the one in question for the "weekly inventory"). The
"copy" and "Inventory" forms are not sub-forms, as Access defines it.

Thanks, John H W
 
D

Dirk Goldgar

John H W said:
Logical I have a "main" form which has the particulars of the form.
One this form I have two command buttons which each opens a different
form (one for "copies made" and the one in question for the "weekly
inventory"). The "copy" and "Inventory" forms are not sub-forms, as
Access defines it.

I'm no closer to an explanation than I was when we started. If you'd
like to send me a cut-down copy of your database, containing only the
elements necessary to demonstrate the problem, compacted and then zipped
to less than 1MB in size (preferably much smaller) -- I'll have a look
at it, time permitting. You can send it to the address derived by
removing NO SPAM from the reply address of this message.
 
D

Dirk Goldgar

John H W said:
Logical I have a "main" form which has the particulars of the form.
One this form I have two command buttons which each opens a different
form (one for "copies made" and the one in question for the "weekly
inventory"). The "copy" and "Inventory" forms are not sub-forms, as
Access defines it.

Now I've had a look at your database, John, and the problem is clear.
You misinformed me when I asked,
1. Is the recordsource of the form a query, or the table itself? If
it's a query, what is the SQL of the query?

and you replied,
1. Table itself.

The Inventory form's recordsource is InventoryQuery, which is a stored
query with this SQL:

SELECT
Inventory.InvFormNo, Form.FormNumber, Inventory.*, Form.FormName
FROM Inventory INNER JOIN Form
ON Inventory.InvFormNo = Form.FormNumber;

If you look at that SQL, you'll see that in the set of fields returned
by the query, there will be two copies of Inventory.InvFormNo -- one
because you asked for it explicitly, and one because you included all
fields from Inventory. So, when you set a text box's controlsource to
"Inventory.InvFormNo", which of these fields do you mean? Access
doesn't know.

In my test, if I change the query's SQL to this:

SELECT
Inventory.*, Form.FormNumber, Form.FormName
FROM Inventory INNER JOIN Form
ON Inventory.InvFormNo = Form.FormNumber;

the form works.

Let me point out in passing that your code in the Current event of form
Inventory:

If Form_Inventory.fmInvFormNo <> nTemp Then
Form_Inventory.fmInvFormNo.Value = nTemp
End If

.... is a little off the mark, though it will work. I gather that you
added the "Form_Inventory" qualifier in an attempt to make this work.
But since this code is running *on* form Inventory, you don't need that
qualifier. I prefer to explicitly qualify the controls and fields on
the form with the keyword "Me", as in:

If Me.fmInvFormNo <> nTemp Then
Me.fmInvFormNo = nTemp
End If

.... but even that is only actually necessary in rare circumstances.
Further, I recommend against using the class module name as the
qualifier for a form. There are a number of pitfalls to that. If you
need to refer to some other open form besides the one the code is
running on, it's better to go through the Forms collection; e.g.,

Forms!Inventory!fmInvFormNo

But none of this is the source of your problem in this case. As far as
I can tell, it all comes down to that query, which you told me didn't
exist.
 
G

Guest

Dirk:

My apology for not remembering the query. The problem has gone away.

Thanks again,
John H W
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top