#Name? error

S

Stephen Raftery

Hi guys,
This may seem a very simple problem. I have some VBA code that returns
information about a data set.
When I call this function from a report, it works just fine. But when I call
it from a form, I just get the #Name? message all the way down.
Both form and report are in the same database file, and the VBA function is
in a separate general module in the same file.
I have tried changing the call so that the form simply calls the NZ function
- still no lick, I just get #Name?

Stephen
 
S

Stephen Raftery

Further info, I am using Access 2010 beta, and the databse is A03 format.
The control has Control Source '=getnames([mon])', where Mon is a field in
the underlying table.
If I change the Control Source to Mon, it works fine, but with the Getnames
function all I get is #Name?.
When I change the ControlSource to '=Nz([Mon])' the same problem occurs.
 
J

John W. Vinson

Hi guys,
This may seem a very simple problem. I have some VBA code that returns
information about a data set.
When I call this function from a report, it works just fine. But when I call
it from a form, I just get the #Name? message all the way down.
Both form and report are in the same database file, and the VBA function is
in a separate general module in the same file.
I have tried changing the call so that the form simply calls the NZ function
- still no lick, I just get #Name?

Stephen

Care to post your code? It's a bit hard to debug from here.
 
S

Stephen Raftery

The code in my Getnames() function works just fine. The problem is that the
function does not get called in the first place. The ControlSource for one of
my textboxes is '=Getnames(mon)', where Mon is a field in the underlying
table., but the function never gets called. I have a similar control in a
report which works fine.
So the problem is somewhere in the way that the function gets called, not
the logic of the function itself.

Stephen
 
J

John Spencer

If you are using a continuous form, you should be calling that function in
your query as a column.

In a continuous form, assigning the function directly to a control means that
the (probably) first record will be used to determine the value for every row.
If your function cannot handle nulls and returns an error based on that
first value then every row will have the error. So it could be your code that
is causing the problem or there may be some other cause.

You might try putting a bit of code in the current event of the form to force
it to recalculate each time you move to the next record. If you do and the
error disappears, then you know that the code works (in most cases). If you
still have an error, then further investigation is required.


John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 

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