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,
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.