forms referencing

D

Dominic Vella

Once upon a time I could reference form fields using something like
Forms("frmMyForm")![record_id]

It seems Access 2007 has stopped me from making such references.

Can anyone help me with a work around.

Thanks

Dominic
 
A

Arvin Meyer [MVP]

You can use:

Forms!frmMyForm![record_id]

from inside the form, in VBA code, you can also use:

Me.[record_id]
 
D

Dominic Vella

Outside referencing doesn't seem to work.

If I put the statement in a the VBA code for a form named "frmOtherForm"
the referencing doesn't work.

Also I use the reference in some of my queries too, such as in list boxes
which updates according to the current record.

Still, why 2007. I've used this referencing since Access97 days. This 2007
is so frustrating it's killed my business.


Dom

Arvin Meyer said:
You can use:

Forms!frmMyForm![record_id]

from inside the form, in VBA code, you can also use:

Me.[record_id]
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Dominic Vella said:
Once upon a time I could reference form fields using something like
Forms("frmMyForm")![record_id]

It seems Access 2007 has stopped me from making such references.

Can anyone help me with a work around.

Thanks

Dominic
 
D

Dirk Goldgar

Dominic Vella said:
Once upon a time I could reference form fields using something like
Forms("frmMyForm")![record_id]

It seems Access 2007 has stopped me from making such references.

No, it hasn't. That reference format works fine in Access 2007, assuming
that "frmMyForm" is the name of an open form and "record_id" is the name of
a control on that form.
Can anyone help me with a work around.

No workaround should be necessary. What exactly are you experiencing that
makes you think that reference style doesn't work? Could it be you
misspelled the name of the form or control?
 
A

Arvin Meyer [MVP]

Perhaps, it's not the syntax, but rather a sandbox issue.

Put your app in a Trusted Location and allow code execution outside the
sandbox.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Dominic Vella said:
Outside referencing doesn't seem to work.

If I put the statement in a the VBA code for a form named "frmOtherForm"
the referencing doesn't work.

Also I use the reference in some of my queries too, such as in list boxes
which updates according to the current record.

Still, why 2007. I've used this referencing since Access97 days. This
2007 is so frustrating it's killed my business.


Dom

Arvin Meyer said:
You can use:

Forms!frmMyForm![record_id]

from inside the form, in VBA code, you can also use:

Me.[record_id]
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Dominic Vella said:
Once upon a time I could reference form fields using something like
Forms("frmMyForm")![record_id]

It seems Access 2007 has stopped me from making such references.

Can anyone help me with a work around.

Thanks

Dominic
 
D

Dominic Vella

when I try (in the frmOther module, and with frmMyForm already loaded)
intTest=Forms("frmMyForm")![record_id]
intTest=Forms("frmMyForm")!txtRecordId
intTest=Forms("frmMyForm")!txtRecordId
strTest=Forms(0).Name
intTest=Forms(0).Controls("txtRecordId")
they all fail.

I Get an error 40036: Method 'Item' of Object 'Forms' failed.
Of course strTest=Forms(1).Name gets an invalid number error

I've tried:
MsgBox CurrentProject.AllForms("frmMyForm").Name works fine.
MsgBox CurrentProject.AllForms("frmMyForm").txtRecordId doesn't work


Considering that it was developed with Access2000, could it be some
importing problems related, ie, a Visual Basic reference or a Form without
proper control references?

I guess I'm really asking if I should use a special importing/conversion
process or try building the database again from scratch?

It really isn't working.


Dom



Dirk Goldgar said:
Dominic Vella said:
Once upon a time I could reference form fields using something like
Forms("frmMyForm")![record_id]

It seems Access 2007 has stopped me from making such references.

No, it hasn't. That reference format works fine in Access 2007, assuming
that "frmMyForm" is the name of an open form and "record_id" is the name
of a control on that form.
Can anyone help me with a work around.

No workaround should be necessary. What exactly are you experiencing that
makes you think that reference style doesn't work? Could it be you
misspelled the name of the form or control?

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 
D

Dominic Vella

I don't think so because it's all in the same database

Dom
Arvin Meyer said:
Perhaps, it's not the syntax, but rather a sandbox issue.

Put your app in a Trusted Location and allow code execution outside the
sandbox.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Dominic Vella said:
Outside referencing doesn't seem to work.

If I put the statement in a the VBA code for a form named "frmOtherForm"
the referencing doesn't work.

Also I use the reference in some of my queries too, such as in list boxes
which updates according to the current record.

Still, why 2007. I've used this referencing since Access97 days. This
2007 is so frustrating it's killed my business.


Dom

Arvin Meyer said:
You can use:

Forms!frmMyForm![record_id]

from inside the form, in VBA code, you can also use:

Me.[record_id]
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Once upon a time I could reference form fields using something like
Forms("frmMyForm")![record_id]

It seems Access 2007 has stopped me from making such references.

Can anyone help me with a work around.

Thanks

Dominic
 
D

Dirk Goldgar

Dominic Vella said:
when I try (in the frmOther module, and with frmMyForm already loaded)
intTest=Forms("frmMyForm")![record_id]
intTest=Forms("frmMyForm")!txtRecordId
intTest=Forms("frmMyForm")!txtRecordId
strTest=Forms(0).Name
intTest=Forms(0).Controls("txtRecordId")
they all fail.

I Get an error 40036: Method 'Item' of Object 'Forms' failed.
Of course strTest=Forms(1).Name gets an invalid number error

To me, that looks very much like the VB project in your database is corrupt.
If Forms(0).Name fails, and there's at least one open form, something is
very wrong, and it's not the control reference format. I suppose it's
possible that it's a broken reference, though, and you want to check that
first.
I've tried:
MsgBox CurrentProject.AllForms("frmMyForm").Name works fine.
MsgBox CurrentProject.AllForms("frmMyForm").txtRecordId doesn't work

AllForms is a different collection, and it holds a different type of object:
an AccessObject, not a Form object at all. So those results are as I'd
expect in any case.
Considering that it was developed with Access2000, could it be some
importing problems related, ie, a Visual Basic reference or a Form without
proper control references?

A broken reference is a possibility, I suppose. See if these steps outlined
by Doug Steele help:

http://www.accessmvp.com/djsteele/AccessReferenceErrors.html
I guess I'm really asking if I should use a special importing/conversion
process or try building the database again from scratch?

What did you do to get where you are? If you had a working Access 2000 .mdb
file, you should be able to just open it in Access 2007 and have it work, so
long as it is in a trusted location. If it's not in a trusted location, VBA
code may be suppressed (although you would normally get a notification to
that effect), and you might find that Sandbox Mode disables some functions.

If your database is corrupt, you might try creating a new, blank one and
importing all the objects from either the corrupt one or from the original,
pre-conversion version of the database.
 
A

Arvin Meyer [MVP]

Try the Trusted Location before dismissing it. Allow all code to run if
prompted by a security warning. Only that way, will you be able to diagnose
the problem.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Dominic Vella said:
I don't think so because it's all in the same database

Dom
Arvin Meyer said:
Perhaps, it's not the syntax, but rather a sandbox issue.

Put your app in a Trusted Location and allow code execution outside the
sandbox.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Dominic Vella said:
Outside referencing doesn't seem to work.

If I put the statement in a the VBA code for a form named
"frmOtherForm" the referencing doesn't work.

Also I use the reference in some of my queries too, such as in list
boxes which updates according to the current record.

Still, why 2007. I've used this referencing since Access97 days. This
2007 is so frustrating it's killed my business.


Dom

You can use:

Forms!frmMyForm![record_id]

from inside the form, in VBA code, you can also use:

Me.[record_id]
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


Once upon a time I could reference form fields using something like
Forms("frmMyForm")![record_id]

It seems Access 2007 has stopped me from making such references.

Can anyone help me with a work around.

Thanks

Dominic
 

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