Q. Problem with command button opening/loading form

J

Jim Jones

Hi,

I have a problem when I click on a command button on my subform named
"mysubform", it gives me an error that it cant find the name of
"mysubform".

The error:
Run-time error '2450'

"MyDatabase can't find the form "mysubform" referred to
in a macro expression or Visual Basic code."

Then, when I click on Debug, it points to this code:

Private Sub Form_Load()
UniqueCarID = Forms("CustomerCarData").UniqueCarID
End Sub

One thing I'll point out is that there appears to be one file name
UniqueCarID. But those are two different fields.

I even changed the name but it still gives the same exact error.

Also, the first one should be spelled UniqueCarId, but when I try to
change it to the proper spelling, VB insists
on changing it back to ID (in caps).


Can you help?

Thanks,
Jim
 
A

Allen Browne

There seems to be some confusion about is being referred to here.

The problem line does not contain the word "mysubform".

What is UniqueCarId? Is it a field in the subform's recordset? The name of a
text box on the subform? The name of the subform control?

Why are you trying to set the value of UniqueCarId in the form's Load event?
Without knowing what it is, this doesn't make sense, e.g. if it is a bound
control you are dirtying it whenever the subform loads?

What is Forms("CustomerCarData")? Is this the main form? If it is the
subform, this will not work as subforms are not part of the Forms
collection.

VBA is not case sensitive, so UniqueCarId and UniqueCarID will both refer to
the same thing, so it does not really matter. You may be able to avoid this
problem by unchecking the Name Correct options under Tools | Options |
General, then compacting the database (Tools | Databaes Utilities |
Compact). It may also be necessary to declare a variable with the case the
way you want it, compile, save, remove the variable, and compile again.
 
J

Jim Jones

There seems to be some confusion about is being referred to here.

The problem line does not contain the word "mysubform".

What is UniqueCarId? Is it a field in the subform's recordset? The name of a
text box on the subform? The name of the subform control?

Why are you trying to set the value of UniqueCarId in the form's Load event?
Without knowing what it is, this doesn't make sense, e.g. if it is a bound
control you are dirtying it whenever the subform loads?

What is Forms("CustomerCarData")? Is this the main form? If it is the
subform, this will not work as subforms are not part of the Forms
collection.

VBA is not case sensitive, so UniqueCarId and UniqueCarID will both refer to
the same thing, so it does not really matter. You may be able to avoid this
problem by unchecking the Name Correct options under Tools | Options |
General, then compacting the database (Tools | Databaes Utilities |
Compact). It may also be necessary to declare a variable with the case the
way you want it, compile, save, remove the variable, and compile again.

Alan,

OK, the problem is a little more simplified now. I didn't have to do
anything with re-compiling.

What I had to do is re-create the button to open the form from my
subform.

A problem still exists: The form that pops up, does not reflect the
UniqueCarID in the field, which it should get from the underlying
subform. Instead, it just says "0".

Is this enough information for you to help me, in light of the small,
if any prograss I made ?

Thanks,
jim
 
A

Allen Browne

Not really, Jim. I still have no idea what "mysubform" is, so I cannot
comment on the problem line.
 
J

Jim Jones

There seems to be some confusion about is being referred to here.

The problem line does not contain the word "mysubform".

What is UniqueCarId? Is it a field in the subform's recordset? The name of a
text box on the subform? The name of the subform control?

Why are you trying to set the value of UniqueCarId in the form's Load event?
Without knowing what it is, this doesn't make sense, e.g. if it is a bound
control you are dirtying it whenever the subform loads?

What is Forms("CustomerCarData")? Is this the main form? If it is the
subform, this will not work as subforms are not part of the Forms
collection.

VBA is not case sensitive, so UniqueCarId and UniqueCarID will both refer to
the same thing, so it does not really matter. You may be able to avoid this
problem by unchecking the Name Correct options under Tools | Options |
General, then compacting the database (Tools | Databaes Utilities |
Compact). It may also be necessary to declare a variable with the case the
way you want it, compile, save, remove the variable, and compile again.

Allen,

Indeed you were right - there was some confusion as to what was being
referenced here.

I corrected it. The pop up form now pops up, with the correct number
I expect to see.

THE FIX was to make sure I was referencing the form field name and NOT
the table field name.

Thanks,
Jim
 

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