Forms Methods

  • Thread starter Thread starter Morris.C
  • Start date Start date
M

Morris.C

I am in the middle of converting an Access97 database to Access2003.
I've come across an annoying fault/error in a section of my VBA script
that works under 97, but fails in 2003.

Here's the part of the code that's not working.
The form it's from is "frm_Edit_Job" and it's contained in the onClick
event of a button.
.....
DoCmd.Openform frm_Cancel_Job (Works fine)
Forms!frm_Cancel_Job!Text01 = Me!Text01 (Fails here.)
.....
I've tried:
Forms!frm_Cancel_Job!Text01 = Forms!frm_Edit_Job!Text01.

Both fail with: Run-time error '40036'
Method 'Item' of object 'Forms' failed

I've checked the methods for Forms! and can't find a method that is
connected with setting the value of a text box in a form that is open but
not the active form.

Again, this works under Access97.

Any help would be appreciated.

Thanks.
 
There are quotes missing from the OpenForm line, but there could also be an
incipient corruption in the A97 mdb code.

1. Using A97, change the code to:
DoCmd.Openform "frm_Cancel_Job"
Forms!frm_Cancel_Job!Text01 = Me!Text01
and verify this works in A97.

2. Close Access. Decompile a copy of the database by entering something like
this at the command prompt while Access is not running. It is all one line,
and include the quotes. Use the path to the Access 97 version of
msaccess.exe:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

3. Open A97. Compact the database.

4. Open a code window, and check that it compiles okay.

5. Try the conversion again.

BTW, if you are not yet experienced with A2003, there are several "gotchas"
you may need to be aware of. See:
Converting from Access 97 to 2000, 2002 or 2003
at:
http://allenbrowne.com/ser-48.html
 
There are quotes missing from the OpenForm line, but there could also
be an incipient corruption in the A97 mdb code.

1. Using A97, change the code to:
DoCmd.Openform "frm_Cancel_Job"
Forms!frm_Cancel_Job!Text01 = Me!Text01
and verify this works in A97.

Sorry Allen, I just typed it in wrong.
What I actually do is:
strForm = "frm_Cancel_Job"
DoCmd.Openform strForm.
This works fine in both A97 and A2003.

I *will* try your decompile process as well as visit your website info.
Thanks
Morris.C
Melbourne.
 
I just found this when I looked at the Help for the Forms property:
"You can use the Forms property to return a *read-only* reference to the
Forms collection and its related properties."
Does this mean I can't set the value of a text box in an open Form from
another form?
 
No, it just means you can't add or remove a Form object to the Forms
collection. (Not directly, anyway.) It's the collection itself that is
read-only, not the members (Forms) of the collection.
 

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

Similar Threads


Back
Top