Method 'Form' of object '_SubForm' failed

I am getting this error message "Method 'Form' of object '_SubForm' failed", when my code On Current runs (see code below), when I click on cmdGrowth (which opens another form-Growth) and when I click on the close button for the Growth form. Prior to today this functioned fine. I was making some coding changes today, but not anything having to do with this section of code or the cmdGrowth button (at least as far as I am aware-I got kind of deep into it, so I am not able to completely retrace my tracks). I cannot find reference to this error message anywhere. Can someone please help me make sense of the error message and maybe look at my code to see if there is something there that I am missing? Is it possible my Growth form got corrupted somehow in what I was doing? Any ideas would be appreciated!

Thank you,

Private Sub Form_Current()
On Error GoTo Form_Current_Err

'When ClientInfo is not a new record, run the following code
If Me.NewRecord = False Then
' Synchs FindName and current record

Forms!frmClientInfo!cboFindName = Forms!frmClientInfo!ClientID

'If Program = Pregnant Woman, cmdGrowth.enable = false
'and DueDate.visible = true

If Me!frmEnrollment.Form!Program = "Pregnant Woman" Then
Me!cmdGrowth.Enabled = False
Me!DueDate.Visible = True

'Otherwise cmdGrowth.enable = true and DueDate.visible = false

Me!cmdGrowth.Enabled = True
Me!DueDate.Visible = False
End If

End If

Exit Sub

MsgBox Error$
Resume Form_Current_Exit

End Sub

Post your answer or comment

comments powered by Disqus
Method 'CurrentDb' of object '_Application' failed

I am getting the error above when I try to use the form wizard. So Win 2000 Server, Access 97 updates 1 and 2.



I have this add data form. When I click on the add button it runs a series of DoCmd.RunSQL commands to make the additions.

It's developed in Access 2002 as a 2000 file. It runs fine on Access 2002, but on SOME Windows 2000 running Access 2000 machines, I encouter this error. I ran the debugger to find out where the error is occuring:

Me!txtSampleID = LocIDs(N)

LocIDs(100) is declared as Integer, and this line above is set in a loop.

The error I get is a Microsoft Access error: Method 'Value' of object '_Textbox' failed

I tried changing the line to

Me.txtSampleID.Value = LocIDs(N)

Now it crashes the entire program.

I've encoutered this error before in another subprocedure. I got around it by putting in some error trapping code, forcing it to run, and this worked. But doesn't work here.

I need some assistance......I am getting this Run-Time Error Method 'ItemData of Object' _ListBox' Failed what I am doing wrong? Here is a copy of my code and also should the code be under Sub Form1 or Option Compare Database/Option Explicit? Again I am new to this world of VBA.Here is my code...Any Assistance would be greatly appericated.

Private Sub Form_Current()
Dim oItem As Variant
Dim oItem1 As Variant
Dim bFound As Boolean
Dim sTemp As String
Dim sTemp1 As String
Dim sValue As String
Dim sChar As String
Dim iCount As Integer
Dim iCount1 As Integer
Dim iListItemsCount As Long
Dim iListItemsCount1 As Long

sTemp = Nz(Me!ErrorCodeDescriptionList88.Value, ";")
sTemp1 = Nz(Me!ErrorCodesandCorrections.Value, ";")
iListItemsCount = 0
iListItemsCount1 = 0
bFound = False
iCount = 0
iCount1 = 0
Call ClearListBox

For iCount = 1 To Len(sTemp) + 1
sChar = Mid(sTemp, iCount, 1)
If StrComp(sChar, ";") = 0 Or iCount = Len(sTemp) + 1 Then
bFound = False
If StrComp(Trim(Me!ErrorCodeDescriptionList88.ItemDat a(iListItemsCount)), Trim(sValue)) = 0 Then
Me!ErrorCodeDescriptionList88.Selected(iListItemsC ount) = True
bFound = True
End If
iListItemsCount = iListItemsCount + 1
Loop Until bFound = True Or iListItemsCount = Me!ErrorCodeDescriptionList88.ListCount
sValue = ";"
sValue = sValue & sChar
End If
Next iCount

For iCount1 = 1 To Len(sTemp1) + 1
sChar = Mid(sTemp1, iCount1, 1)
If StrComp(sChar, ";") = 0 Or iCount1 = Len(sTemp) + 1 Then
bFound = False
If StrComp(Trim(Me!ErrorCodesandCorrections.ItemData( iListItemsCount)), Trim(sValue)) = 0 Then
Me!ErrorCodesandCorrections.Selected(iListItemsCou nt) = True
bFound = True
End If
iListItemsCount1 = iListItemsCount1 + 1
Loop Until bFound = True Or iListItemsCount1 = Me!ErrorCodesandCorrections.ListCount
sValue = ";"
sValue = sValue & sChar
End If
Next iCount1
End Sub
Private Sub ClearListBox()
Dim iCount As Integer
Dim iCount1 As Integer

For iCount = 0 To Me!ErrorCodeDescriptionList88.ListCount
Me!ErrorCodeDescriptionList88.Selected(iCount) = False
Next iCount

For iCount1 = 0 To Me!ErrorCodesandCorrectionsList.ListCount
Me!ErrorCodesandCorrectionsList.Selected(iCount1) = False
Next iCount1
End Sub
Private Sub Save_Record_Click()
Dim oItem As Variant
Dim oItem1 As Variant
Dim sTemp As String
Dim sTemp1 As String
Dim iCount As Integer
Dim iCount1 As Integer

iCount = 0
If Me!ErrorCodeDescriptionList88.ItemsSelected.Count 0 Then
For Each oItem In Me!ErrorCodeDescriptionList88.ItemsSelected
If iCount = 0 Then
sTemp = sTemp & Me!ErrorCodeDescriptionList88.ItemData(oItem)
iCount = iCount + 1
sTemp = sTemp & ";" & Me!ErrorCodeDescriptionList88.ItemData(oItem)
iCount = iCount + 1
End If
Next oItem
MsgBox "Nothing was selected from the list", vbInformation
Exit Sub 'Nothing was selected
End If

iCount1 = 0
If Me!ErrorCodesandCorrectionsList.ItemsSelected.Coun t 0 Then
For Each oItem1 In Me!ErrorCodesandCorrectionsList.ItemsSelected
If iCount1 = 0 Then
sTemp1 = sTemp & Me!ErrorCodesandCorrectionsList.ItemData(oItem)
iCount1 = iCount1 + 1
sTemp1 = sTemp1 & ";" & Me!ErrorCodesandCorrectionsList.ItemData(oItem)
iCount1 = iCount1 + 1
End If
Next oItem1
MsgBox "Nothing was selected from the list", vbInformation
Exit Sub 'Nothing was selected
End If

Me!ErrorCodeDescription.Value = sTemp
Me!ErrorCodesandCorrectionsList.Value = sTemp1

End Sub
Private Sub clrList_Click()
Call ClearListBox
Me!ErrorCodeDescription.Value = Null
Me!ErrorCodesandCorrections.Value = Null
End Sub Attached Files (151.3 KB, 0 views) Reply With Quote 08-03-2012, 12:44 PM #2 ssanfu VIP Windows XP Access 2000 Join Date Sep 2010 Location Anchorage, Alaska, USA Posts 1,932 I don't have A2K7, so I couldn't open your dB. I have no idea what you are trying to do, so I made a form and a couple of list boxes to test your code. I put the code behind a button so I could run it when I wanted. This is what I found so far.

What are your list box names????
In the sub Form_Current(), you have two list boxes named "ErrorCodeDescriptionList88" and "ErrorCodesandCorrections"

In the subs Sub ClearListBox(), you have two list boxes named "ErrorCodeDescriptionList88" and "ErrorCodesandCorrectionsList"

In the sub Sub Save_Record_Click(), you have two list boxes named "ErrorCodeDescriptionList88" and "ErrorCodesandCorrectionsList"

In the sub Sub clrList_Click(), you have two list boxes named "ErrorCodeDescription" and "ErrorCodesandCorrections"

In the sub Form_Current(), it looks like the list boxes are multi-select (because this of Me!ErrorCodeDescriptionList88.ItemData(iListItemsC ount))
Walking through the code, these two variables have a semi-colon:
Code: sTemp = nz(Me!ErrorCodeDescriptionList88.Value, ";") sTemp1 = nz(Me!ErrorCodesandCorrections.Value, ";") If the list boxes are multi-select, you cannot get the values this way.

Next there is a line:
Code: Call ClearListBox The list boxes are cleared of any selections before any other code uses the list boxes... ??

Code: If StrComp(Trim(Me!ErrorCodeDescriptionList88.ItemData(iListItemsCount)), Trim(sValue)) = 0 Then The variable "sValue" is not initalized, so it is NULL. Comparing a NULL with anything (including NULL) results in a NULL. So "NULL = 0" is FALSE.
And there are no items selected because of the call to "ClearListBox".

Then the Do - Loop....The first time through the the DO loop is OK.
The second time it goes into an endless look because "bFound" is never TRUE and "iListItemsCount" doesn't get reset - it keeps increasing. It starts off greater than Me!ErrorCodeDescriptionList88.ListCount.
Code: Loop Until bFound = True Or iListItemsCount = Me!ErrorCodeDescriptionList88.ListCount (this might be the cause of the error message)

That is as far as I got with the code.

These two lines should be at the top of every code page:
Code: Option Compare Database Option Explicit -----
should the code be under Sub Form1 I wouldn't think so. But I don't know what the purpose of the code is for.

If you use (in A2K3) the dot (Me.) notation instead of the bang (Me!), the compiler catches undeclared variables (if Option Explicit is at the top of the page).

Help please! I'm using Access 2007 in Windows XP and in need of some advice.

I have a few access VBA programs written in Access 2007 to help me manipulate data that I have in a database. I've used these programs without issue for several months without a problem.

Today I installed Visio 2010 and all of a sudden none of my Access programs will run. As soon as one of my VBA macros tries to execute a sql query the program fails and I get an error message that says:

Run-time error '-214748113 (8000ffff)':
Method 'Connection' of object '_CurrentProject' failed

I get this error message in other databases as well anytime I'm trying to execute a sql query via code.

An example of a type of query I'm running via code:

CurrentProject.Connection.Execute "Update RawData set Subject_Name = 'English' where Subject_Name = 'Reading and Writing'"

This has functioned without fail for several months. I've made no changes except for installing Visio 2010 earlier today.

so the progression is:

- everything is fine, Access 2007 macros work
- install Visio 2010 and Access 2007 macros no longer work

Please help!!!!!! Thanks in advance for any help.

i am having a few problems

when i got to try and use the create a table using wizard i get the error message : Method 'CurrentDb' of object '_Application' failed

i went online and it told me that a specific VBA reference needs to be added. (Dao360.dll)

i found it on my system via browse in under tools/references. ("C:Program FilesCommon FilesMicrosoft SharedDAODao360.dll")

but when i click ok, it comes up with the error : Error in loading DLL

i have tried everything from registering the file again via regsvr32, to reinstallin the whole office suite.

i am using office 2003

any help will be greatly appreciated


I'm getting - Method 'InsideHeight' of object 'PlotArea' failed. I'm using Access Automation to build Powerpoint presentations and on a slide where I have 2 charts I'm lining up the 2 chart's plot areas so the data on each chart line up. The error does not happen every time I run the code. It appears to happen randomly. I tried putting a Doevents in the code in case there was a timing issue but that has not corrected it. Now once I get the error and the code breaks I do a next and sometimes it continues and other time I get the error again. If I continue to do Next eventually it continues (could be 3 or 4 times before it runs). Here is my code:

Public Sub Lineup_Charts(xChart1 As Powerpoint.Chart, xChart2 As Powerpoint.Chart)
On Error GoTo Lineup_Charts_Err

Dim sChart1Top As Single
Dim sChart2Top As Single
Dim sChart1Left As Single
Dim sChart2Left As Single

' xChart1 is the data Chart
' xChart2 is the norm Chart
xChart2.PlotArea.InsideHeight = xChart1.PlotArea.InsideHeight ' This is where it fails

xChart2.PlotArea.InsideWidth = xChart1.PlotArea.InsideWidth
sChart1Top = xChart1.Parent.TOP + xChart1.PlotArea.InsideTop + xChart1.ChartArea.TOP
sChart2Top = xChart2.Parent.TOP + xChart2.PlotArea.InsideTop + xChart2.ChartArea.TOP
If sChart1Top > sChart2Top Then
xChart2.Parent.TOP = xChart2.Parent.TOP + (sChart1Top - sChart2Top)
If sChart1Top < sChart2Top Then
xChart2.Parent.TOP = xChart2.Parent.TOP - (sChart2Top - sChart1Top)
End If
End If
sChart1Left = xChart1.Parent.Left + xChart1.PlotArea.InsideLeft + xChart1.ChartArea.Left
sChart2Left = xChart2.Parent.Left + xChart2.PlotArea.InsideLeft + xChart1.ChartArea.Left
If sChart1Left > sChart2Left Then
xChart2.Parent.Left = xChart2.Parent.Left + (sChart1Left - sChart2Left)
If sChart1Left < sChart2Left Then
xChart2.Parent.Left = xChart2.Parent.Left - (sChart2Left - sChart1Left)
End If
End If
Exit Sub

gErrorProcedure = "Lineup_Charts"
DoCmd.OpenForm "GenericErrorForm"
Resume Lineup_Charts_Exit

End Sub

I saw a Post on another site where the author solved the problem in Excel. In that post the answer was turning on ScreenUpdating in Excel. Now as far as I know there isn't a setting for this in Powerpoint. Does anyone have any suggestions on how I could work around this issue? Thanks for the Help!


I am trying to run reports in Access 2007 Database (output is an Excel file) one after the other.
The first report works perfectly, but when I try to run the second report, I get the error
"Run Time Error 1004: Method Range of Object _Global Failed"

(Both of these reports are same except the first report is for 1Month Sales and Second Report is for 6 Months).

I have to close and re-open the database every time I need to run these reports one after the other.

Here is the code:

'Rearrange Columns
.Selection.Cut Destination:=Range("E:L") (This is where code fails when the second report is run with the above error message)

I have googled the error but couldn't find a satisfactory answer...

I have just installed Office 2003 and I am trying to use an old database in Access 2000 file format.

Within the forms are activeX Calender controls. I am now getting a runtime error when I try reference these controls:

Runtime Error - Method 'Value' of object '_CustomControl' failed.

This happens when I am trying to either change the control or get a value from it.

i.e. Me.CalControl = Now() or Me.FrmDate = Me.CalControl

I know that the controls are referenced (Microsoft Access Calender Control 7.0)

Can anyone help please?

I have a form (EventComms1) with a subform (Communcation subform)that when I select an item from the combobox (cmboCommunicationName) should update a date field (CommunicationDueDate) on my subform based on the date on the main form (EventTimeStartDay) but it says the "Method 'item' of object 'forms' failed. Here is the code (which isn't elegant but worked when I applied it in another place so apart from the forms and subform syntax works). I know its something to do with my syntax but I have looked in help and copied what I thought should work:

If Forms![EventComms1]![Communication subform].Form![cmboCommunicationName].Value = 1 Then
Forms![EventComms1]![Communication subform].Form![CommunicationDueDate] = DateAdd("d", -7,
End If
If Forms![EventComms1]![Communication subform].Form![cmboCommunicationName].Value = 2 Then
Forms![EventComms1]![Communication subform].Form![CommunicationDueDate] = DateAdd("d", -4,
End If
If Forms![EventComms1]![Communication subform].Form![cmboCommunicationName].Value = 3 Then
Forms![EventComms1]![Communication subform].Form![CommunicationDueDate] = DateAdd("d", -1,
End If
If Forms![EventComms1]![Communication subform].Form![cmboCommunicationName].Value = 4 Then
Forms![EventComms1]![Communication subform].Form![CommunicationDueDate] = DateAdd("d", -1,
End If
If Forms![EventComms1]![Communication subform].Form![cmboCommunicationName].Value = 5 Then
Forms![EventComms1]![Communication subform].Form![CommunicationDueDate] = DateAdd("d", 7,
End If
If Forms![EventComms1]![Communication subform].Form![cmboCommunicationName].Value = 6 Then
Forms![EventComms1]![Communication subform].Form![CommunicationDueDate] = DateAdd("d", 7,
End If
If Forms![EventComms1]![Communication subform].Form![cmboCommunicationName].Value = 7 Then
Forms![EventComms1]![Communication subform].Form![CommunicationDueDate] = DateAdd("d", 14,
End If
If Forms![EventComms1]![Communication subform].Form![cmboCommunicationName].Value = 8 Then
Forms![EventComms1]![Communication subform].Form![CommunicationDueDate] = DateAdd("d", 14,
End If

Can anyone see what i'm doing wrong please. Thanks

I've been working for sometime on a subform problem where I receive the error:

"Method 'Form' of object '_subform' failed Runtime error '-2146500594 (800f0003)':"

This error message comes up when I try to enable or disable a control on a subform using:

"Me![subfrmUpdateAgent].Form![W].Enabled = False"

The syntax has worked before. Has anyone ever run into this before? What's it mean? Any ideas?


I have been having quite a fight this morning with accessing a table in my FE DB via an ADO Recordset object.

I am working on creating cfg tables in both the client and server databases. Next up was to fetch the application version from each table. Then to compare and make sure the client and server code matches. Seems simple enough.

So my code for the server config table works perfectly / flawlessly. Using that I capture both the run-time domain (DEV / QA / PROD) and also the version string.

Next I built a class based on the class accessing the server table. Adjusted the SQL to be correct for the local FE table. The query string executes perfectly in a query window, but not so when run from an ADO object in VBA.

Da code...

	'This API searches for the KeyValue based on the KeyName and Run-Time Domain
Public Function LocateKeyValue(keyname As String) As String
On Error GoTo Err_LocateKeyValue

  Dim adoRS As ADODB.Recordset
  Dim strSQL As String

  'Define attachment to database table specifics
  Set adoRS = New ADODB.Recordset
  adoRS.ActiveConnection = CurrentProject.Connection
  adoRS.Source = "cfg"
  adoRS.CursorType = adOpenDynamic
  adoRS.LockType = adLockPessimistic

  'Define a query to look for the KeyValue based on the KeyName and Run-Time Domain
  strSQL = "SELECT cfg.keyvalue " & _
    "FROM cfg " & _
    "WHERE (((cfg.keyname)='" & keyname & "') AND ((cfg.domain)='" & domain & "'));"

  'Open query results
  adoRS.Open strSQL

  'Was no record found?
  If adoRS.BOF Or adoRS.EOF Then
    LocateKeyValue = ""
    'Fetch the values found
    keyvalue = Nz(adoRS!keyvalue, 0)
    'And return the fetched keyvalue
    LocateKeyValue = keyvalue
  End If

  'Close the database table

  'Clean up the connection to the database
  Set adoRS = Nothing

  Exit Function

  Call errorhandler_MsgBox("Class: clsObjCfgTbl, Function: LocateKeyValue()")
  LocateKeyValue = ""
  Resume Exit_LocateKeyValue

End Function

At first I was getting this sort of error:

	Date: 20110823 Time: 10:49:07 UserID: c_mlueck
Error Source: Class: clsObjCfgTbl, Function: LocateKeyValue()
Error Number: -2147467259
Error Description: Automation error
Unspecified error

So I did a bit of searching for that, came across a MS document telling how to get additional information about such errors:

So I added that to my error handler. However, not much help for the effort:

	Date: 20110823 Time: 11:29:40 UserID: c_mlueck
Error Source: Class: clsObjCfgTbl, Function: LocateKeyValue()
Error Number: -2147467259
Error Description: Automation error
Unspecified error 
MessageText: Unspecified error

Since adding that code, I have also received this type of error... which is the type the code presently throws.

	Date: 20110823 Time: 11:42:24 UserID: c_mlueck
Error Source: Class: clsObjCfgTbl, Function: LocateKeyValue()
Error Number: -2147467259
Error Description: Method 'Open' of object '_Recordset' failed
MessageText: Unspecified error

I have seen references that a reserved word has been used, which causes the error only when being run from VBA. No keywords jump out at me. Do you see one?

And pretty much the same query runs on the server... though that is a different ADO connection, which is doing pass-through queries.

Suggestions please??!?!?! Thanks!

i got a problem said that "Method Open the object _Recordset Failed"
what should i do - -'

Well, thanks to SJ McAbney I have a nice chart on referencing subforms from the main form and what not. I'm still having trouble making it work, so I am sure there is something that I don't understand here.

	Private Sub cmdNewCat_Click() 
Me.frmNavSNewCat.Visible = True
Me!frmNavSNewCat.Form!txtCatParID = Me.txtCurrent '

Access 2003
Beginning/intermediate user
inherited complex, occasionally poor structure DB

How to set up a combobox for a search VBA which isn't text type but is a foreign key to another table? For data integrity I think I need to use the foreign key in my student as the record source in my subform, when I do that it displays the correct ID (but it's numerical). How to get the group name from the groups table to display instead?

I have a form(unbound)/subform(RS by Query). I'm using comboboxes and some code found here to dynamically set the filter property of the subform. One of my fields is exhibiting strange behavior that the others are not.

After filtering when updating a value in the Status column the new value selected is being applied to all (filtered) records that share the previously chosen value.

On the attached example if I change the status name field of the first record to departed the second to last row's value will also change.

EDIT: So found that I had been using the Status Name (from different table) not the Status ID which is the value stored in the table the query is based off of.

EDIT: Changed the query to reflect the numerical status ID and the bound section of the subform field. now it's bad to worse...when it rains it pours. Now I'm getting a ''run-time error '-2146500594 (800f000e)' Method 'Form' of object '_SubForm' failed", When I try any of the sorts.

EDIT: removed all my excess fields and comboboxes for sort control. Adding them 1 at a time. Back to original question


i want to get a value from a filed in the subform. i just cant get it to work. this is what i am using:

Sub update2()
MsgBox Forms!WorkGroups!EmployeesperWorkgroup.Form!FirstN ame
End Sub

Mainform Name: WorkGroups
Subform Name: EmployeesperWorkgroup
A control on the subform: FirstName (textbox)

the subform is in datasheet view.

This gives me error saying
"Runtime error '-2146500594(800f000e)':
Method "Form" of object "_Subform" failed."


***The text in the SQL is case sensitive, the field names in my table were lower case, in the VBA SQL each were capitalized***

Please help! I am trying to export data using file system object and receive the following error:

Run-time error '-2147467259 (80004005)'"
Method 'Open' of object '_Recordset' Failed

The routine writes a blank .txt file to my desktop. When debugging, it fails rs.Open line. The query is valid and works in query window.

References selected: Visual Basic For Applications, Microsoft Access 11.0 Object Library, OLE Automation, Microsoft DAO 3.6 Object Library, Microsoft ActiveX Data Objects 2.1 Library, Microsoft Scripting Runtime

MS Access Version: 2003 Professional Edition (11.6566.8117) SP2

The "NASDAQ" table:
date open close 2006-01-03 10718 10809 2005-12-01 10806 10717 2005-11-01 10569 10440

Code: Sub XPORT() Dim fso As FileSystemObject Dim txt As TextStream Dim rs As ADODB.Recordset Dim s As String Set fso = New FileSystemObject Set txt = fso.CreateTextFile("C:Documents and Settingsxjp1pyuDesktopxportit.txt", True) Set rs = New ADODB.Recordset rs.ActiveConnection = CurrentProject.Connection rs.Open "SELECT Date, Open, Close FROM NASDAQ", , adOpenForwardOnly, adLockReadOnly txt.WriteLine "Date, Open, Close" Do While Not rs.EOF s = """" & FormatDateTime(rs("Date"), vbShortDate) & """, " s = s & FormatNumber(rs("Open"), 2, vbFalse, vbFalse, vbFalse) & ", " s = s & FormatNumber(rs("Close"), 2, vbFalse, vbFalse, vbFalse) txt.WriteLine s rs.MoveNext Loop rs.Close txt.Close End Sub

I create my DB some time ago (2 months). At that time all works, but now I just try open it and entry some records, but when I open form I got this
''run-time error '-2146500594 (800f000e)' Method 'Form' of object '_SubForm' failed"
and this
"The expression on error you entered as the event property setting produced the following error: a problem occurred while microsoft office access was communicating with the ole server or activex control."

I am shocked because my db is unusable anymore. How it can be? Maybe it because that I reinstall my Windows and Office some time ago? But before have XP and Office 2003 and now also. How get my DB to work again???

I get this error when I try to run a code snippet for creating a graph in MS Excel. Not surprisingly, Using the MS Access VBA Object Browser, I find that the method Chart Wizard is present within the Excel library Chart Class.

I also find that there are 6 Visual Basic for Applications libraries on my Windows XP SP3 computer.


The library that is in use may be found along the following path:

C:program filescommon filesmicrosoft sharedvbavba6(file name begins with VB, but is truncated)

Any thoughts on how to configure MS Access to use a different VBA library? Alternately, does anyone have thoughts on how to fix this error?

For reference, I'm attaching a copy of the the code I am reviewing exactly as it was published in Alison Balter's book "Mastering Microsoft Access 2000 Development" (ISBN: 0-0672-31484-3). I have already searched the web for an errata on this book to see if there is a known fix and have found none.

	Private Sub cmdCreateGraph_Click()
    On Error GoTo cmdCreateGraph_Err
    Dim rstData As ADODB.Recordset
    Dim rstCount As ADODB.Recordset
    Dim fld As ADODB.Field
    Dim rng As Excel.Range
    Dim objWS As Excel.Worksheet
    Dim intRowCount As Integer
    Dim intColCount As Integer
    'Display Hourglass
    DoCmd.Hourglass True
    Set rstData = New ADODB.Recordset
    rstData.ActiveConnection = CurrentProject.Connection
    Set rstCount = New ADODB.Recordset
    rstCount.ActiveConnection = CurrentProject.Connection
    'Attempt to create Recordset and launch Excel
    If CreateRecordset(rstData, rstCount, "qrySalesByCountry") Then
        If CreateExcelObj() Then
            Set objWS = gobjExcel.ActiveSheet
            intRowCount = 1
            intColCount = 1
            'Loop though Fields collection using field names
            'as column headings
            For Each fld In rstData.Fields
                If fld.Type  adLongVarBinary Then
                    objWS.Cells(1, intColCount).Value = fld.Name
                    intColCount = intColCount + 1
                End If
            Next fld
            'Send Recordset to Excel
            objWS.Range("A1").CopyFromRecordset rstData, 500
            'Format Data
            With gobjExcel
                Set rng = .Selection
                .Selection.NumberFormat = "$#,##0.00"
                'Add a Chart Object
                .ActiveSheet.ChartObjects.Add(135.75, 14.25, 607.75, 301).Select
                'Run the Chart Wizard
                .ActiveChart.ChartWizard Source:=Range(rng.Address), _
                    Gallery:=xlColumn, _
                    Format:=6, PlotBy:=xlColumns, CategoryLabels:=1, SeriesLabels _
                    :=1, HasLegend:=1, Title:="Sales By Country", CategoryTitle _
                    :="", ValueTitle:="", ExtraTitle:=""
                'Make Excel Visible
                .Visible = True
            End With
            MsgBox "Excel Not Successfully Launched"
        End If
        MsgBox "Too Many Records to Send to Excel"
    End If
    DoCmd.Hourglass False
    Set rstData = Nothing
    Set rstCount = Nothing
    Set fld = Nothing
    Set rng = Nothing
    Set objWS = Nothing
    DoCmd.Hourglass False
    Exit Sub
    MsgBox "Error # " & Err.Number & ": " & Err.Description
    Resume cmdCreateGraph_Exit
End Sub

V12 Engine


In my subform's oncurrent event I want to change the value of a text box (docid) on the main form.
The name of the subform is : AsnadList
This code doesn't work:

Private Sub Form_Current()
Me.Parent.docid = Me.DocumentId
End Sub

I keep receiving this error message:
Method 'Parent' of object '_Form_AsnadList" failed

What's the problem?

I have a form with multiple subforms. The ADO connection is opened to populate the fields in the form and subforms and closed afterwards so it does not slow down the servers. In Access 2003, it works fine, but 2007 causes all the subforms to unload when the connection tries to close.

To close the connection, I use this code
Set connection = Nothing

When it runs connection.close it goes straight to form unload for the subforms. Then it tries to load the subforms after it unloads them. Then I get an error saying
Run-time error'-2147417848 (80010108)':
Method populatedata of object form_transactions failed.

If anyone has any idea, please let me know.

I was tasked with debugging code and stummbled across this error message
"Method 'Save' of object '_Workbook' failed"
Here's the portion of the code that pertains to this...

Set TestBook = Workbooks.Open(XlsPath & strXlsFileName)
Set TestSheet = TestBook.Worksheets(1)

' Delete First Row in the XLS
Cells(1, 1).EntireRow.Delete

' Last 2 columns in XLS
For k = 1 To 2
Cells(1, 3).EntireColumn.Delete
Next k

finalrow = TestSheet.Range("A65000").End(xlUp).Row

For i = 1 To finalrow
TestSheet.Cells(i, 3) = UFirstthree
Next i
TestBook.Application.DisplayAlerts = False
strXlsFileName = Dir()

MsgBox "Data processing successful."

Hi guys,

I was wondering if any of you would be able to help me out. I'm trying to get a button on an access form to open crystal reports and pass two parameters through to it from controls on the access form.

This is what I have at them moment:

	Private Sub openRpt_Click()

Dim selForm As String
Dim CrystalReport1 As Crystal.crystalReport
Set CrystalReport1 = CreateObject("crystal.crystalreport")

CrystalReport1.Connect = "ODBC;UID=ID;PWD=PW;DSN=dsn;Database=dbname"
CrystalReport1.ReportFileName = "O:DatabasesCReportsSingle Project Up To Burn Rate.rpt"
'CrystalReport1.WindowTitle = "Single Project Up To Burn Rate"
'CrystalReport1.WindowMaxButton = False
'CrystalReport1.WindowMinButton = False
'CrystalReport1.WindowState = crptMaximized

selForm = 'selection formula

CrystalReport1.SelectionFormula = selForm
CrystalReport1.ParameterFields(0) = "PeriodStart(" & Me.yearCode & ");true"
CrystalReport1.ParameterFields(1) = "ProjectNo(" & Me.projectNumber & ");true"
CrystalReport1.Destination = crptToWindow
CrystalReport1.Action = 1

End Sub

With this I'm currently getting a "Method 'Action' of object 'CrystalCtrl' failed" on the line CrystalReport1.Action = 1

My Ideal solution would open Crystal Reports in its own window, but if thats not possible opening in the access form would do.

currently running:
Access 2003
Windows Server 2003
Crystal Reports XI


I am trying to automate importing data from a text file to a table but the text file changes each time. I want to use an open common dialog box from a form to allow the user to browse and select the text box and then save the path in a variable. I can get the dialog box to open and allow the user to select a file, but when you click on 'OPEN' command button, I get runtime error 20476 - Method 'ShowOpen' of object '1CommonDialog' failed. Can anyone give me suggestions on how to get past this error?

I have a database setup to track daily tasks. When you open the database a login form automatically opens with a drop down box of names and a textbox for passwords. When one of my users opens the database he gets the error "Method 'Recordset' of object '_form_sfrmLogin' failed. Error -2147024770 (8007007e)." You hit ok then he gets an error when he tries to click on the drop down box the error occurs on the code the combo box wizzard sets up. Does anyone have any idea what causes this. I have 10 users using the same database and he is the only one that this happens to. I have checked to make sure all the references are there and they are. Any help would be much appreciated.



Not finding an answer? Try a Google search.