Solved

Access 2000 Run-time error 40036:  Method 'Item' of object 'Forms' failed - Please help

Posted on 2004-04-30
5
2,146 Views
Last Modified: 2007-12-19
I keep getting a Run-time error 40036:  Method 'Item' of object 'Forms' failed error in Access 2000.
This problem is strange.  Some variation of very simple code below worked earlier today and now it doesn't.  I don't know what I changed or did but it I can't figure out how to fix it.  I have tried so many different ways that I don't remember which set of code was the original one that worked.  The frmChangeLeaseGetLeaseNumber form opens but when the second line of code runs I get the error.  The txtOpenedFrom control exists.  Here is some variations that will not work for me:

Private Sub cmdChangeMasterLease_Click()

    DoCmd.OpenForm "frmChangeLeaseGetLeaseNumber"
    Forms!frmChangeLeaseGetLeaseNumber.Controls("txtOpenedFrom").Value = "Change Master"
   
End Sub

I have also tried:

Private Sub cmdChangeMasterLease_Click()

    DoCmd.OpenForm "frmChangeLeaseGetLeaseNumber"
    Forms!frmChangeLeaseGetLeaseNumber!txtOpenedFrom = "Change Master"
   
End Sub

and

Private Sub cmdChangeMasterLease_Click()

    DoCmd.OpenForm "frmChangeLeaseGetLeaseNumber"
    Forms!frmChangeLeaseGetLeaseNumber!txtOpenedFrom.Value = "Change Master"
   
End Sub


and:

Private Sub cmdChangeMasterLease_Click()

    DoCmd.OpenForm "frmChangeLeaseGetLeaseNumber"
    Forms("frmChangeLeaseGetLeaseNumber").Controls("txtOpenedFrom") = "Change Master"
   
End Sub

Private Sub cmdChangeMasterLease_Click()

    DoCmd.OpenForm "frmChangeLeaseGetLeaseNumber"
    Forms("frmChangeLeaseGetLeaseNumber").Controls("txtOpenedFrom") .Value= "Change Master"
   
End Sub

I have also tried declaring a form variable and using that in the code but that hasn't helped either.
Please help me!

Thankyou,

Chad
0
Comment
Question by:travelcenters
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:phileoca
ID: 10962744
Forms!Yourform.Controls!YourField.Value = "value"

Notice, after YourForm is .Controls

Forms!frmChangeLeaseGetLeaseNumber.Controls!txtOpenedFrom.Value = "Change Master"

0
 

Author Comment

by:travelcenters
ID: 10962798
phileoca,

That doesn't work either.  I don't think it is a syntax issue.  I think something else is happening.  I searched the internet for similar problems and the ones I found all said that the problem was sporadic and that one day the code would work and the next day it wouldn't.  There is some bug in my opinion.  Has anyone seen this before?

Thanks again,

Chad
0
 
LVL 36

Accepted Solution

by:
SidFishes earned 160 total points
ID: 10962857
hmmm...try setting your value before opening the form...

Public myValue


myvalue =  "Change Master"
DoCmd.OpenForm "frmChangeLeaseGetLeaseNumber"


then in the form_open event of "frmChangeLeaseGetLeaseNumber"

me!txtOpenedFrom = myValue
0
 

Author Comment

by:travelcenters
ID: 10963076
SidFishes,
Thank you so much!!  You have no idea how long this has been driving me crazy.

Sincerely,
Chad
0
 
LVL 36

Expert Comment

by:SidFishes
ID: 10963149
oh yes i do...been there..:)...glad to help
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question