Solved

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

Posted on 2004-04-30
5
2,170 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

733 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