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!
6 8461
Sounds like a corruption in the database. You should try to rebuild the form and see if that helps.
Brad.
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!
-
DoCmd.OpenForm "frmCreateContact", acNormal
-
'Forms("frmCreateContact").SetFocus
-
Forms!frmCreateContact.Controls!txtClientCode = Forms!ClientsAdmin.Controls!ClientCode
-
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.
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.
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: - Private Sub Form_Load()
-
' set up the connection and recordset.
-
Set conn = CurrentProject.Connection
-
-
'set client code
-
'MsgBox Me.ClientCode
-
'Me.txtClientCode = "gfkgjdflg"
-
'empty all other controls
-
Me.Title = ""
-
Me.FName = ""
-
Me.LName = ""
-
Me.Position = ""
-
Me.txtSpecify = ""
-
Me.Phone = ""
-
Me.GSM = ""
-
Me.Email1 = ""
-
Me.Email2 = ""
-
Me.Remarks = ""
-
'empty listbox
-
Set MyRS = New ADODB.Recordset
-
MyRS.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
-
Do While Not MyRS.EOF
-
MyRS.Delete
-
Loop
-
MyRS.Close
-
Set MyRS = Nothing
-
'-------------------------------
-
'populate listbox
-
sSQL = "SELECT * FROM tblClientContacts WHERE " & _
-
"tblClientContacts.ClientCode = " & Me.ClientCode
-
-
Set MyRS = New ADODB.Recordset
-
MyRS.Open sSQL, conn, adOpenDynamic, adLockOptimistic
-
Set MyRS2 = New ADODB.Recordset
-
MyRS2.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
-
'transfer searched details to qryContactList
-
Do While Not MyRS.EOF
-
With MyRS2
-
.AddNew
-
.Fields(0).Value = MyRS.Fields(0).Value 'ContactID
-
.Fields(1).Value = MyRS.Fields(1).Value 'ClientCode
-
.Fields(2).Value = MyRS.Fields(2).Value 'Title
-
.Fields(3).Value = MyRS.Fields(3).Value 'FName
-
.Fields(4).Value = MyRS.Fields(4).Value 'LName
-
.Fields(5).Value = MyRS.Fields(5).Value 'Position
-
.Fields(6).Value = MyRS.Fields(6).Value 'Phone
-
.Fields(7).Value = MyRS.Fields(7).Value 'GSM
-
.Fields(8).Value = MyRS.Fields(8).Value 'Email1
-
.Fields(9).Value = MyRS.Fields(9).Value 'Email2
-
.Fields(10).Value = MyRS.Fields(10).Value 'Remarks
-
.Update
-
End With
-
Loop
-
-
Me.lstContacts.Requery
-
Me.Title.SetFocus
-
-
MyRS.Close
-
Set MyRS = Nothing
-
MyRS2.Close
-
Set MyRS2 = Nothing
-
conn.Close
-
Set conn = Nothing
-
End Sub
Thanks
Yes on Form Load I have: - Private Sub Form_Load()
-
' set up the connection and recordset.
-
Set conn = CurrentProject.Connection
-
-
'set client code
-
'MsgBox Me.ClientCode
-
'Me.txtClientCode = "gfkgjdflg"
-
'empty all other controls
-
Me.Title = ""
-
Me.FName = ""
-
Me.LName = ""
-
Me.Position = ""
-
Me.txtSpecify = ""
-
Me.Phone = ""
-
Me.GSM = ""
-
Me.Email1 = ""
-
Me.Email2 = ""
-
Me.Remarks = ""
-
'empty listbox
-
Set MyRS = New ADODB.Recordset
-
MyRS.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
-
Do While Not MyRS.EOF
-
MyRS.Delete
-
Loop
-
MyRS.Close
-
Set MyRS = Nothing
-
'-------------------------------
-
'populate listbox
-
sSQL = "SELECT * FROM tblClientContacts WHERE " & _
-
"tblClientContacts.ClientCode = " & Me.ClientCode
-
-
Set MyRS = New ADODB.Recordset
-
MyRS.Open sSQL, conn, adOpenDynamic, adLockOptimistic
-
Set MyRS2 = New ADODB.Recordset
-
MyRS2.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
-
'transfer searched details to qryContactList
-
Do While Not MyRS.EOF
-
With MyRS2
-
.AddNew
-
.Fields(0).Value = MyRS.Fields(0).Value 'ContactID
-
.Fields(1).Value = MyRS.Fields(1).Value 'ClientCode
-
.Fields(2).Value = MyRS.Fields(2).Value 'Title
-
.Fields(3).Value = MyRS.Fields(3).Value 'FName
-
.Fields(4).Value = MyRS.Fields(4).Value 'LName
-
.Fields(5).Value = MyRS.Fields(5).Value 'Position
-
.Fields(6).Value = MyRS.Fields(6).Value 'Phone
-
.Fields(7).Value = MyRS.Fields(7).Value 'GSM
-
.Fields(8).Value = MyRS.Fields(8).Value 'Email1
-
.Fields(9).Value = MyRS.Fields(9).Value 'Email2
-
.Fields(10).Value = MyRS.Fields(10).Value 'Remarks
-
.Update
-
End With
-
Loop
-
-
Me.lstContacts.Requery
-
Me.Title.SetFocus
-
-
MyRS.Close
-
Set MyRS = Nothing
-
MyRS2.Close
-
Set MyRS2 = Nothing
-
conn.Close
-
Set conn = Nothing
-
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). -
Do While Not MyRS.EOF
-
With MyRS2
-
.AddNew
-
.Fields(0).Value = MyRS.Fields(0).Value 'ContactID
-
.Fields(1).Value = MyRS.Fields(1).Value 'ClientCode
-
.Fields(2).Value = MyRS.Fields(2).Value 'Title
-
.Fields(3).Value = MyRS.Fields(3).Value 'FName
-
.Fields(4).Value = MyRS.Fields(4).Value 'LName
-
.Fields(5).Value = MyRS.Fields(5).Value 'Position
-
.Fields(6).Value = MyRS.Fields(6).Value 'Phone
-
.Fields(7).Value = MyRS.Fields(7).Value 'GSM
-
.Fields(8).Value = MyRS.Fields(8).Value 'Email1
-
.Fields(9).Value = MyRS.Fields(9).Value 'Email2
-
.Fields(10).Value = MyRS.Fields(10).Value 'Remarks
-
.Update
-
End With
-
Loop
-
So we have two options.
1. Infinite loop causes fail
2. Code fails before.
I hope this makes sence.
Yes on Form Load I have: - Private Sub Form_Load()
-
' set up the connection and recordset.
-
Set conn = CurrentProject.Connection
-
-
'set client code
-
'MsgBox Me.ClientCode
-
'Me.txtClientCode = "gfkgjdflg"
-
'empty all other controls
-
Me.Title = ""
-
Me.FName = ""
-
Me.LName = ""
-
Me.Position = ""
-
Me.txtSpecify = ""
-
Me.Phone = ""
-
Me.GSM = ""
-
Me.Email1 = ""
-
Me.Email2 = ""
-
Me.Remarks = ""
-
'empty listbox
-
Set MyRS = New ADODB.Recordset
-
MyRS.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
-
Do While Not MyRS.EOF
-
MyRS.Delete
-
Loop
-
MyRS.Close
-
Set MyRS = Nothing
-
'-------------------------------
-
'populate listbox
-
sSQL = "SELECT * FROM tblClientContacts WHERE " & _
-
"tblClientContacts.ClientCode = " & Me.ClientCode
-
-
Set MyRS = New ADODB.Recordset
-
MyRS.Open sSQL, conn, adOpenDynamic, adLockOptimistic
-
Set MyRS2 = New ADODB.Recordset
-
MyRS2.Open "qryContactListbox", conn, adOpenDynamic, adLockOptimistic
-
'transfer searched details to qryContactList
-
Do While Not MyRS.EOF
-
With MyRS2
-
.AddNew
-
.Fields(0).Value = MyRS.Fields(0).Value 'ContactID
-
.Fields(1).Value = MyRS.Fields(1).Value 'ClientCode
-
.Fields(2).Value = MyRS.Fields(2).Value 'Title
-
.Fields(3).Value = MyRS.Fields(3).Value 'FName
-
.Fields(4).Value = MyRS.Fields(4).Value 'LName
-
.Fields(5).Value = MyRS.Fields(5).Value 'Position
-
.Fields(6).Value = MyRS.Fields(6).Value 'Phone
-
.Fields(7).Value = MyRS.Fields(7).Value 'GSM
-
.Fields(8).Value = MyRS.Fields(8).Value 'Email1
-
.Fields(9).Value = MyRS.Fields(9).Value 'Email2
-
.Fields(10).Value = MyRS.Fields(10).Value 'Remarks
-
.Update
-
End With
-
Loop
-
-
Me.lstContacts.Requery
-
Me.Title.SetFocus
-
-
MyRS.Close
-
Set MyRS = Nothing
-
MyRS2.Close
-
Set MyRS2 = Nothing
-
conn.Close
-
Set conn = Nothing
-
End Sub
Thanks
Did you forget to declare the Object Variable conn as in: - Dim conn As ADODB.Connection
-
Set conn = CurrentProject.Connection
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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....
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
| |