473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error 40036 VBA Ms Access 2003

LonelyBunny
hi i'm new here. im developping on ms access 2003 for a planning db for a company's staff.

I have a contact adress book to create for each client.I need to copy a value from the ClientsAdmin form to the frmCreateContact form with the code:

DoCmd.OpenForm "frmCreateContact", acNormal
'Forms("frmCreateContact").SetFocus
Forms!frmCreateContact.Controls!txtClientCode = Forms!ClientsAdmin.Controls!ClientCode

Here I have tried use explicit reference coz im having error 40036 (Method Item of object Form failed).
Trying to set focus etc does not help...

Thanks for suggesting me the possible solution to this!
Jun 15 '07 #1
6 8461
BradHodge
166 Expert 100+
Sounds like a corruption in the database. You should try to rebuild the form and see if that helps.

Brad.
Jun 15 '07 #2
FishVal
2,653 Expert 2GB
hi i'm new here. im developping on ms access 2003 for a planning db for a company's staff.

I have a contact adress book to create for each client.I need to copy a value from the ClientsAdmin form to the frmCreateContact form with the code:

DoCmd.OpenForm "frmCreateContact", acNormal
'Forms("frmCreateContact").SetFocus
Forms!frmCreateContact.Controls!txtClientCode = Forms!ClientsAdmin.Controls!ClientCode

Here I have tried use explicit reference coz im having error 40036 (Method Item of object Form failed).
Trying to set focus etc does not help...

Thanks for suggesting me the possible solution to this!
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "frmCreateContact", acNormal
  2. 'Forms("frmCreateContact").SetFocus
  3. Forms!frmCreateContact.Controls!txtClientCode = Forms!ClientsAdmin.Controls!ClientCode
  4.  
Hmm

This should work.
I suggest you to set breakpoint in line#3 and check in VBA Immediate window what actually fails "Forms!frmCreateContact.Controls!txtClientCode " or "Forms!ClientsAdmin.Controls!ClientCode".

Good luck.
Jun 15 '07 #3
ADezii
8,834 Expert 8TB
hi i'm new here. im developping on ms access 2003 for a planning db for a company's staff.

I have a contact adress book to create for each client.I need to copy a value from the ClientsAdmin form to the frmCreateContact form with the code:

DoCmd.OpenForm "frmCreateContact", acNormal
'Forms("frmCreateContact").SetFocus
Forms!frmCreateContact.Controls!txtClientCode = Forms!ClientsAdmin.Controls!ClientCode

Here I have tried use explicit reference coz im having error 40036 (Method Item of object Form failed).
Trying to set focus etc does not help...

Thanks for suggesting me the possible solution to this!
Do you have any code in the Open, Load, or Current Event of frmCreateContact? If you do, please post it.
Jun 15 '07 #4
Do you have any code in the Open, Load, or Current Event of frmCreateContact? If you do, please post it.
Yes on Form Load I have:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. ' set up the connection and recordset.
  3. Set conn = CurrentProject.Connection
  4.  
  5. 'set client code
  6. 'MsgBox Me.ClientCode
  7. 'Me.txtClientCode = "gfkgjdflg"
  8. 'empty all other controls
  9. Me.Title = ""
  10. Me.FName = ""
  11. Me.LName = ""
  12. Me.Position = ""
  13. Me.txtSpecify = ""
  14. Me.Phone = ""
  15. Me.GSM = ""
  16. Me.Email1 = ""
  17. Me.Email2 = ""
  18. Me.Remarks = ""
  19. 'empty listbox
  20. Set MyRS = New ADODB.Recordset
  21. MyRS.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
  22. Do While Not MyRS.EOF
  23.     MyRS.Delete
  24. Loop
  25. MyRS.Close
  26. Set MyRS = Nothing
  27. '-------------------------------
  28. 'populate listbox
  29. sSQL = "SELECT * FROM tblClientContacts WHERE " & _
  30. "tblClientContacts.ClientCode = " & Me.ClientCode
  31.  
  32. Set MyRS = New ADODB.Recordset
  33. MyRS.Open sSQL, conn, adOpenDynamic, adLockOptimistic
  34. Set MyRS2 = New ADODB.Recordset
  35. MyRS2.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
  36. 'transfer searched details to qryContactList
  37. Do While Not MyRS.EOF
  38.     With MyRS2
  39.         .AddNew
  40.         .Fields(0).Value = MyRS.Fields(0).Value 'ContactID
  41.         .Fields(1).Value = MyRS.Fields(1).Value 'ClientCode
  42.         .Fields(2).Value = MyRS.Fields(2).Value 'Title
  43.         .Fields(3).Value = MyRS.Fields(3).Value 'FName
  44.         .Fields(4).Value = MyRS.Fields(4).Value 'LName
  45.         .Fields(5).Value = MyRS.Fields(5).Value 'Position
  46.         .Fields(6).Value = MyRS.Fields(6).Value 'Phone
  47.         .Fields(7).Value = MyRS.Fields(7).Value 'GSM
  48.         .Fields(8).Value = MyRS.Fields(8).Value 'Email1
  49.         .Fields(9).Value = MyRS.Fields(9).Value 'Email2
  50.         .Fields(10).Value = MyRS.Fields(10).Value 'Remarks
  51.         .Update
  52.     End With
  53. Loop
  54.  
  55. Me.lstContacts.Requery
  56. Me.Title.SetFocus
  57.  
  58. MyRS.Close
  59. Set MyRS = Nothing
  60. MyRS2.Close
  61. Set MyRS2 = Nothing
  62. conn.Close
  63. Set conn = Nothing
  64. End Sub
Thanks
Jun 18 '07 #5
FishVal
2,653 Expert 2GB
Yes on Form Load I have:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. ' set up the connection and recordset.
  3. Set conn = CurrentProject.Connection
  4.  
  5. 'set client code
  6. 'MsgBox Me.ClientCode
  7. 'Me.txtClientCode = "gfkgjdflg"
  8. 'empty all other controls
  9. Me.Title = ""
  10. Me.FName = ""
  11. Me.LName = ""
  12. Me.Position = ""
  13. Me.txtSpecify = ""
  14. Me.Phone = ""
  15. Me.GSM = ""
  16. Me.Email1 = ""
  17. Me.Email2 = ""
  18. Me.Remarks = ""
  19. 'empty listbox
  20. Set MyRS = New ADODB.Recordset
  21. MyRS.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
  22. Do While Not MyRS.EOF
  23. MyRS.Delete
  24. Loop
  25. MyRS.Close
  26. Set MyRS = Nothing
  27. '-------------------------------
  28. 'populate listbox
  29. sSQL = "SELECT * FROM tblClientContacts WHERE " & _
  30. "tblClientContacts.ClientCode = " & Me.ClientCode
  31.  
  32. Set MyRS = New ADODB.Recordset
  33. MyRS.Open sSQL, conn, adOpenDynamic, adLockOptimistic
  34. Set MyRS2 = New ADODB.Recordset
  35. MyRS2.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
  36. 'transfer searched details to qryContactList
  37. Do While Not MyRS.EOF
  38. With MyRS2
  39. .AddNew
  40. .Fields(0).Value = MyRS.Fields(0).Value 'ContactID
  41. .Fields(1).Value = MyRS.Fields(1).Value 'ClientCode
  42. .Fields(2).Value = MyRS.Fields(2).Value 'Title
  43. .Fields(3).Value = MyRS.Fields(3).Value 'FName
  44. .Fields(4).Value = MyRS.Fields(4).Value 'LName
  45. .Fields(5).Value = MyRS.Fields(5).Value 'Position
  46. .Fields(6).Value = MyRS.Fields(6).Value 'Phone
  47. .Fields(7).Value = MyRS.Fields(7).Value 'GSM
  48. .Fields(8).Value = MyRS.Fields(8).Value 'Email1
  49. .Fields(9).Value = MyRS.Fields(9).Value 'Email2
  50. .Fields(10).Value = MyRS.Fields(10).Value 'Remarks
  51. .Update
  52. End With
  53. Loop
  54.  
  55. Me.lstContacts.Requery
  56. Me.Title.SetFocus
  57.  
  58. MyRS.Close
  59. Set MyRS = Nothing
  60. MyRS2.Close
  61. Set MyRS2 = Nothing
  62. conn.Close
  63. Set conn = Nothing
  64. End Sub
Thanks
Hi!

Have you tried to trace the code in step-by-step mode?
If so where does it fail? If not you should definitely do this to help yourself and others to detect a reason of failing. The code behaiviour is too context dependant to detect where does it fail.

I guess that code execution will never pass line #53 bcz you have an infinite loop (lines #37-#53).

Expand|Select|Wrap|Line Numbers
  1. Do While Not MyRS.EOF
  2. With MyRS2
  3. .AddNew
  4. .Fields(0).Value = MyRS.Fields(0).Value 'ContactID
  5. .Fields(1).Value = MyRS.Fields(1).Value 'ClientCode
  6. .Fields(2).Value = MyRS.Fields(2).Value 'Title
  7. .Fields(3).Value = MyRS.Fields(3).Value 'FName
  8. .Fields(4).Value = MyRS.Fields(4).Value 'LName
  9. .Fields(5).Value = MyRS.Fields(5).Value 'Position
  10. .Fields(6).Value = MyRS.Fields(6).Value 'Phone
  11. .Fields(7).Value = MyRS.Fields(7).Value 'GSM
  12. .Fields(8).Value = MyRS.Fields(8).Value 'Email1
  13. .Fields(9).Value = MyRS.Fields(9).Value 'Email2
  14. .Fields(10).Value = MyRS.Fields(10).Value 'Remarks
  15. .Update
  16. End With
  17. Loop
  18.  
So we have two options.
1. Infinite loop causes fail
2. Code fails before.

I hope this makes sence.
Jun 18 '07 #6
ADezii
8,834 Expert 8TB
Yes on Form Load I have:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. ' set up the connection and recordset.
  3. Set conn = CurrentProject.Connection
  4.  
  5. 'set client code
  6. 'MsgBox Me.ClientCode
  7. 'Me.txtClientCode = "gfkgjdflg"
  8. 'empty all other controls
  9. Me.Title = ""
  10. Me.FName = ""
  11. Me.LName = ""
  12. Me.Position = ""
  13. Me.txtSpecify = ""
  14. Me.Phone = ""
  15. Me.GSM = ""
  16. Me.Email1 = ""
  17. Me.Email2 = ""
  18. Me.Remarks = ""
  19. 'empty listbox
  20. Set MyRS = New ADODB.Recordset
  21. MyRS.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
  22. Do While Not MyRS.EOF
  23.     MyRS.Delete
  24. Loop
  25. MyRS.Close
  26. Set MyRS = Nothing
  27. '-------------------------------
  28. 'populate listbox
  29. sSQL = "SELECT * FROM tblClientContacts WHERE " & _
  30. "tblClientContacts.ClientCode = " & Me.ClientCode
  31.  
  32. Set MyRS = New ADODB.Recordset
  33. MyRS.Open sSQL, conn, adOpenDynamic, adLockOptimistic
  34. Set MyRS2 = New ADODB.Recordset
  35. MyRS2.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
  36. 'transfer searched details to qryContactList
  37. Do While Not MyRS.EOF
  38.     With MyRS2
  39.         .AddNew
  40.         .Fields(0).Value = MyRS.Fields(0).Value 'ContactID
  41.         .Fields(1).Value = MyRS.Fields(1).Value 'ClientCode
  42.         .Fields(2).Value = MyRS.Fields(2).Value 'Title
  43.         .Fields(3).Value = MyRS.Fields(3).Value 'FName
  44.         .Fields(4).Value = MyRS.Fields(4).Value 'LName
  45.         .Fields(5).Value = MyRS.Fields(5).Value 'Position
  46.         .Fields(6).Value = MyRS.Fields(6).Value 'Phone
  47.         .Fields(7).Value = MyRS.Fields(7).Value 'GSM
  48.         .Fields(8).Value = MyRS.Fields(8).Value 'Email1
  49.         .Fields(9).Value = MyRS.Fields(9).Value 'Email2
  50.         .Fields(10).Value = MyRS.Fields(10).Value 'Remarks
  51.         .Update
  52.     End With
  53. Loop
  54.  
  55. Me.lstContacts.Requery
  56. Me.Title.SetFocus
  57.  
  58. MyRS.Close
  59. Set MyRS = Nothing
  60. MyRS2.Close
  61. Set MyRS2 = Nothing
  62. conn.Close
  63. Set conn = Nothing
  64. End Sub
Thanks
Did you forget to declare the Object Variable conn as in:
Expand|Select|Wrap|Line Numbers
  1. Dim conn As ADODB.Connection
  2. Set conn = CurrentProject.Connection
Jun 19 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
6
by: Squirrel | last post by:
I have a command button on a subform to delete a record. The only statement in the subroutine is: DoCmd.RunCommand acCmdDeleteRecord The subform's recordsource is "select * from tblVisit order...
3
by: Rolan | last post by:
I seem to be unable to have a custom error message to appear for Error 10011 (database was unable to append all the data to the table). Each time, the MS Access default error message box appears....
4
by: RM | last post by:
Had VS .Net 2002 installed on W2k Server SP3 and supported a number of web sites. Installed VS .Net 2003 on Friday and now all web sites using .Net & MS ACCESS get this strange error upon open. ...
5
by: Bruce Schechter | last post by:
I just started to develop an ASP.NET application in vs.net 2003 . But each time I try to execute the application (which is basically empty so far), I get a dialog box titled "Microsoft Development...
0
by: Yelena Varshal via AccessMonster.com | last post by:
Hello We have a shortcut for our MS ACCESS application that uses a /Runtime switch because we may have some users that use Runtime. The application worked fine in Access 2000 and was tested with...
6
by: tony.abbitt | last post by:
I have recently installed Office 2007 (SP1) retaining the previous installation of Office 2003. I have converted an Access 2003 database to Access 2007. The database contains the VBA code...
0
by: Sebastian | last post by:
Hello I develop my applications in Access 2002. My development system is running Windows XP SP2 and I have Microsoft Office XP Developer. Microsoft Office XP is at SP3. I used Inno Setup (great...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.