Adding the dao reference Results

Ive tried to activate the DAO reference but when I went to tools, references, there was no such thing as a dao reference. Does anyone know how I can access this reference?

Hi,

I am having a weird problem with my VB code in Access 2003. I made a module which parses through an XML file.
I added these 2 references: Microsoft XML v6.0 (msxml6.dll) and Microsoft XML, version 2.0 (msxml.dll)

I wrote the code, and everything was working fine.
I moved the Database to another computer, made practically no changes (and definately no changes involved with this section of the code). Moved the Database back to my computer, tried to run it and recieved this error:

	Code:
	"Object variable or With block variable not set"

on the last line of code here:

	Code:
	    Dim xmlDoc As DOMDocument
    Dim custList As IXMLDOMNodeList
    Dim cust As IXMLDOMNode
    Dim rstCustomerTable As DAO.Recordset
    Dim rstAddressGenerators As DAO.Recordset
 
    Set rstCustomerTable = CurrentDb.OpenRecordset(strCustomerTable, dbOpenDynaset)
    Set rstAddressGenerators = CurrentDb.OpenRecordset(strAddressTable, dbOpenDynaset)
 
    Set xmlDoc = New DOMDocument
 
    xmlDoc.Load strPathToXML
 
    Set custList = xmlDoc.documentElement.selectNodes("customer")

I recieved this same error on this same line when I first wrote the code but I was able to solve the problem by adding the 2 references. Now, these 2 references are still there but I'm getting the error again!

Does anyone have any idea of what could have went wrong and how i can fix it?!

Thank You for your help,
--Muskilh

I'm trying to get a grip on ADO but I think I should have made sure I had a grasp of DAO first. Now even the simplest Sub Procedure isn't working in my database but it was working last week! All due to me trying to switch the code around to use ADO and lose the DAO references.

Can someone be so kind and take a minute to plop down a DAO example? Afterwards perhaps someone with ADO knowledge convert it?

If you would like to even help me out even more, the example could pertain to my procedure that's not working anymore. Simple.. (well, was before I dove into ADO) references one table with four fields. Procedure is triggered by the user pressing a button on a form. The procedure adds a record (fills in the next four fields). It actually added X number of records (determined by a text field on the form) but I should be able to figure that out again.

I feel so inept.

This is the function my combo box runs, using the command:

	Code:
	Private Sub Combo0_NotInList(NewData As String, Response As Integer)
Response = Append2Table(Me![Combo0], NewData)
End Sub

I get the error 3421 Data type conversion error

Not sure why, it should be working fine.. I have the DAO reference checked (that was my last problem lol)

I hate changinc access versions...



	Code:
	Function Append2Table(cbo As ComboBox, NewData As Variant) As Integer
On Error GoTo Err_Append2Table
    Dim rst As DAO.Recordset
    Dim sMsg As String
    Dim vField As Variant       ' Name of the field to append to.

    Append2Table = acDataErrContinue
    vField = cbo.ControlSource
    If Not (IsNull(vField) Or IsNull(NewData)) Then
        sMsg = "Do you wish to add the entry " & NewData & " for " & cbo.Name & "?"
        If MsgBox(sMsg, vbOKCancel + vbQuestion, "Add new value?") = vbOK Then
            Set rst = CurrentDb.OpenRecordset(cbo.RowSource)
            rst.AddNew
                rst(vField) = NewData
            rst.Update
            rst.Close
            Append2Table = acDataErrAdded
        End If
    End If

Exit_Append2Table:
    Set rst = Nothing
    Exit Function

Err_Append2Table:
    MsgBox "Error " & Err.Number & ": " & Err.Description, vbInformation, "Append2Table()"
    Resume Exit_Append2Table
End Function



Hi,
I'm trying to send an email from Access using automation but I can't get it to work, I don't get any error messages when I try.

I'll give you the background:

Various customers make enquiries via emails to a inbox, the emails contain a spreadsheet which, once received, has to updated and saved. An email is then sent to the customer with the updated spreadsheet

The VBA code behind the button which when clicked should send the email is shown on the attached file.

The VBA code contains the tables tblEmailResults and tblCustomer

Table tblEmailResults stores the following :
1. emailSentTime {time that the email reply was sent}
2. enquiryID {enquiry Identifier}

Table tblCustomer stores the following :
1. Customer {Customer Name}
2. GALname {Name as displayed on the Outlook address list}

I am using Access 97 and have added the following references for the VBA code:

Visual Basic for Applications
Microsoft Access 8.0 Object Library
Microsoft DAO 3.5 Object Library
Outlook 98 Type Library
OLE Automation

I am also using Outlook 98

When I click on the button nothing happens! I don't even get an error message! Greatful for any suggestions getting it to work

How can I to refer to an existing ADO Recordset object variable in a function, given its name as a string?

I have a custom function called from a query. That function includes writing data to an existing fabricated ADO Recordset.

Now I want to generalise the function to write to different recordsets based on an argument.

Clearly, because it comes from a query I can't pass the object reference directly as one would when calling a function from VBA so I must pass the recordset name.

How do I convert that name to a recordset reference inside the function?

If it was DAO I could use the Recordsets collection. I guess I could do the same for the ADO Recordset by adding it to a Collection with its name as the Index when it is created.

However it seems like there should be some straightforward way to refer to the variable by its name. Something like CallByName() but for variables instead of Class Properties and Methods.

Hi all,

I am using VBA in Office XP for the first time.

Firstly, I could not Dim a variable as Database, so I added the DAO 3.6 as a reference. This may be my mistake, I'm not sure.

I then tried to set a RecordSet variable with db.OpenRecordset, and this gave me a mismatch error. What am I doing wrong? This was never a problem when using Access 97.

Dim db As Database
Dim rs As Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("Select * from Statements")

I guess the reference to DAO3.6 may be causing the problem, but I don't know what the correct reference should be. I already have VBA and Access10 references selected, but these do not make the Database Object available.

Thanks in advance.

Hi,
I have a many to many relationship using 3 tables. The database is used to manage courses so the tables are 1)Attendees, 2)Courses 3) Link table (used as a junction table to manage the many to many relationship). I have 228 Attendees that need to be assigned to at least 8 courses.
I have been trying to do a bulk update to the Link table by adding all 228 attendees and then adding the course reference e.g. CourseID (56) but the code I am trying does not see to work.
I am using this attached to a button on a form and the text boxes CourseID and intName are txt boxes on my form. Is this the correct way to do something like this?

Private Sub AddToWrap_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intName As Integer

Set rs = DBEngine(0)(0).OpenRecordset("tblLINK_Att_Cour001" , dbOpenTable, dbAppendOnly)

For intName = 1 To 228
rs.AddNew
rs.Fields("NameID") = intName
rs.Fields("CourseID") = Me.CourseID
rs.Update
Next intName

rs.Close
Set rs = Nothing
End Sub

As I asked before I have some problems with DAO360.
When I try to run a db (Access 2003) on another machines in some cases I get an error the application don't recognize some basic functions like Format().
Even though these functions has nothing to do with DAO I found that removing DAO from refernces and adding it again solve the problem

As my db will be changed to MDE setting the reference on the client machine is not an option.
Now I'm looking for the best option to solve this situation:
1. Will puting the DAO from the developing machine in the same folder of the db on the client machine cause the db to use the correct DAO?
2. If I put the correct DAO in the same folder as the db (As in 1) I guess I can re-register the DAO with the correct one, but this might cause problems with other Access applicatins.
3. using late binding as suggested here http://www.access-programmers.co.uk/...ghlight=dao360

Hi

I'm trying to link a query from access (or stored procedure in Crystal), into Crystal.

Query is called 'LQClients' and is itself based upon a query called 'LQData'

The query call a custom function called 'RoundUp' which just takes a number and round it up to nearest whole. This works perfectly in Access.

When I try to connect the query to Crystal I get:

Database Connector Error: DAO Error Code 0xc0D
Source DAO.Parameters
Description: Undefined function 'Roundup' in expression.

How can I get around this?

Also, I'm ultimately looking to run the Crystal report from a VB6 app, with the datasource being created within VB6. I 'm fine with adding the datasource etc but how would I reference the 'Roundup' function.... in VB6 or Crystal???

Thanks

LeonH

Summary: DAO method for adding an unknown item in a combobox's list to the underlying table

N.B. This article applies to users of the Data Access Objects (DAO) data access method. It is assumed that you are using MS Access 97 to follow this article. If you would like to use the DAO method with MS Access 2000 - or greater - then you may wish to refer to this thread. An ActiveX Data Objects (ADO) method can be found on this thread. Should you have a "User Defined Type not defined" error then refer to this thread.

On occasions whereby you have a set selection displayed within a form's combobox but would allow for the user to add a new option to the underlying table then you can make use of the combobox's NotInList event.

The NotInList event occurs at the moment when the user enters some data into the combobox that isn't already in said control's current list.

Some points to note: This event is only triggered if the combobox's LimitToList property is set to 'Yes'; The combobox's RowSourceType must be set to 'Table/Query'; The combobox must have a RowSource set to either a table or a query.
Assuming that we have on our form a combobox called MyCombo, the following code will offer the user the option to add the new value into the underlying table and - if accepted - add said value.


	Code:
	Private Sub MyCombo_NotInList(NewData As String, Response As Integer)
    
    On Error GoTo Err_ErrorHandler
    
    ' provide text constants to reduce text later and allow for faster execution
    ' due to added speed from the compilation of constants
    Const Message1 = "The data you have entered is not in the current selection."
    Const Message2 = "Would you like to add it?"
    Const Title = "Unknown entry..."
    Const NL = vbCrLf & vbCrLf
    
    ' database and recordset object variables
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    
    ' show message box and evaluate if the user has selected Yes or No
    If MsgBox(Message1 & NL & Message2, vbQuestion + vbYesNo, Title) = vbYes Then
        ' open a connection to the current database
        Set db = CurrentDb
        Set rs = db.OpenRecordset("MyTable")
        ' using the recordset object
        With rs
            .AddNew ' prepare to add a new record
            .Fields("MyField") = NewData ' add unfound data into field
            .Update ' update the table
            .Close ' close the recordset object
        End With
        Response = acDataErrAdded ' confirm record added
    Else
        Me.MyCombo.Undo ' clear the entry in the combobox
        Response = acDataErrContinue ' confirm the record is not allowed
    End If
    
Exit_ErrorHandler:
    ' de-initialise our object variables
    Set rs = Nothing
    Set db = Nothing
    Exit Sub
    
Err_ErrorHandler:
    ' display error message and error number
    MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
    Resume Exit_ErrorHandler
    
End Sub



Hi,

I have created a MS-Access based tool and I am adding below mentioned references at a form load event, it is working fine at my workstation but when I am running this tool in other system it is not working properly because like at my system calendar control version 10 and on that system have version 8, Excel object library 12 and on that system have version 11.

I want that whenever I open the form it will automatically add most latest version in reference. Of below mentioned references.

VBA Access stdole ADODB OWC10 Excel DAO Office MSOWCFLib MSACAL
Sub AddRefs()
Dim loRef As Access.Reference
Dim guid1 As String
Dim guid2 As String
Dim guid3 As String
Dim guid4 As String
Dim guid5 As String
Dim guid6 As String
Dim guid7 As String
Dim guid8 As String
Dim guid9 As String
Dim guid10 As String

guid1 = "{000204EF-0000-0000-C000-000000000046}"
guid2 = "{4AFFC9A0-5F99-101B-AF4E-00AA003F0F07}"
guid3 = "{00020430-0000-0000-C000-000000000046}"
guid4 = "{00000205-0000-0010-8000-00AA006D2EA4}"
guid5 = "{0002E550-0000-0000-C000-000000000046}"
guid6 = "{00020813-0000-0000-C000-000000000046}"
guid7 = "{00025E01-0000-0000-C000-000000000046}"
guid8 = "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}"
guid9 = "{5D0A2606-5783-11D1-B901-00AA00585640}"
guid10 = "{8E27C92E-1264-101C-8A2F-040224009C02}"

On Error Resume Next

With Access.References
.AddFromGuid guid1, 1, 0
.AddFromGuid guid2, 1, 0
.AddFromGuid guid3, 1, 0
.AddFromGuid guid4, 1, 0
.AddFromGuid guid5, 1, 0
.AddFromGuid guid6, 1, 0
.AddFromGuid guid7, 1, 0
.AddFromGuid guid8, 1, 0
.AddFromGuid guid9, 1, 0
.AddFromGuid guid10, 1, 0

End With

' Call a hidden SysCmd to automatically compile/save all modules.
Call SysCmd(504, 16483)
End Sub

I have a CSV file that I have Access import into a table using a scripting FSO and reading each line of the CSV file. For any given import, there will be an unknown number of lines, so there a few loops set up. Something I've done in the past two hours has caused the Access to each column of the CSV file with quotes. For instance, the date 1/1/11 is being picked up as ""1/1/11"", and therefore unrecognized as a date. There are too many fields to find and replace all quotations- but more importantly, it had worked earlier today, so I would like to know what I've screwed up...

During the time that this import stopped working, I had tried some adobe code (and turned on adobe references) in a different Module of the database and added the file location as a string instead of placing it directly in the code. I have tried reversing these actions, but it didn't solve the problem

Here is a sample of my code, if it helps:
Code: Public Sub Importing()Dim rs As DAO.Recordset Dim rsMS4 As DAO.Recordset Dim rsSF As DAO.Recordset Dim FileLocation As String Dim objFSO Dim objFile Dim strdata As String Dim arrData Dim Count As Integer Dim strLine As String Dim VID As String Dim arrFileLines() i = 0 '''SET THE FILE PATHWAY FOR THE CSV FILE HERE''' FileLocation = DLookup("CSVLocation", "filelocations", "id=1") '''IDENTIFY ACCESS TABLES AND CSV FILE''' Set rs = CurrentDb.OpenRecordset("select * from [All VSMP Permit Projects]") Set rsMS4 = CurrentDb.OpenRecordset("select * from [Receiving-Waters-TBL]") Set rsSF = CurrentDb.OpenRecordset("select * from [Support Facility TBL]") Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(FileLocation) '''REACH EACH LINE OF THE CSV FILE''' Do Until objFile.AtEndOfStream 'repeat this process until there's nothing left ReDim Preserve arrFileLines(i) arrFileLines(i) = objFile.ReadLine ' strdata = objFile.ReadLine 'the string data is a line in the file Count = Count + 1 'Will count all the lines i = i + 1 Loop '''FOR EACH LINE OF THE CSV FILE EXCEPT THE HEADER''' '''PUT THE NEW INFO IN THE VSMP TABLE''' For i = 1 To (i - 1) 'start after the header line 'go to the last line of data strdata = arrFileLines(i) 'set the string equal to each line arrData = Split(strdata, ",") 'splits each line into a new column when there's a comma With rs 'in the database rs.AddNew 'make a new line rs.Fields.Item("Date on Info Form") = arrData(1) rs.Fields.Item("Project Permit #") = arrData(2) rs.Fields.Item("Project") = arrData(3) rs.Fields.Item("PPMS #") = arrData(4) rs.Fields.Item("UPC #") = arrData(5) rs.Fields.Item("Permit Status") = arrData(6) End With '''SEND TO NEXT LINE''' Next i '''CLEAN UP THE RSs''' rs.Close rsMS4.Close rsSF.Close '''CONFIRM IMPORT''' MsgBox ("Shizam!") End Sub

I have a database that I have been using for months. It is split. I have made many many updates to the front end, and never had a problem. Well, this last set up changes/updates I made has some sort of problem. Althought the problem does not exist until I make create an accde and then try to open it.

This is the message I get:
the expression you entered has a function name that databasename can't find.

I have read A LOT and tried a million things, but no luck.

I have an autoexecute macro that runs some vba code. It is telling me that it can't find the function in this code. However, for the past 6 months or so, the code in this auto exe and the module for the vba code has not changed at all. Just to be safe, I copied the code from an older version that still works fine, and pasted it in. Still no change.

I read that it might have something to do with the references. I will be honest, I really have no idea about any of the references. However, I am suspicious of one change that I made. I read on one forum aobut the dao reference, may be a problem. I recently added some code that uses dao and creates a recordset, but just does a simple loop through the records. I went into the references and noticed that the dao 3.6 reference was not added. When I tried to add it, it gave me an error saying that there is a duplicate name (module, macro, reference). So i just unchecked the ado reference, and it didn't appear that I needed it. Then it let me add the dao reference. But this still did not fix the problem.

I even created a new database, and copied everything over to it, but this didn't end up working. There were all kinds of missing things, so I gave up on that.

Any ideas on what the problem may be??

Thanks!

Hi All,

I have an access 2002 database with one table in it called "MT_ITEM_LIST" and have added the ADO 3.6 Library to my source references.

I am trying to connect to the table but my code trips up when I try to Open the recordset.

My Current code is as follows:

Public Function searchTable()

Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDbs("MT_ITEM_LIST")
Set rs = dbs.OpenRecordset("MT_ITEM_LIST", dbOpenDynaset)

Dim strSql As String
Dim strSQL2 As String

Dim vSearchItemRef, vSearchItemDesc, vSearchPVNb
Dim vResultItemRef, vResultDC, vResultItemDesc, vResultPVNb, vResultPVName

strSql = "My Test SQL"

Debug.Print strSql

*** CODE TRIPS UP HERE ***
rs.Open strSql, conn, adOpenKeyset, adLockOptimistic

Any suggestions for me?

Thanks.

Quote: Originally Posted by boblarson Yes, that's what I'm talking about. But the big thing is that you need to have the right version selected because any DAO reference for Office Versions 11 and prior will have no knowledge of the ACCDB file format. You need to select the version 12 or 14 in order for it to not have an unrecognized database error. I added a COM reference to Microsoft Office 12.0 Object Library, and Microsoft Office 12.0 Access Database Engine Object Library 12.0.

It made no difference at all.

It still fails on this line (unrecognizable database format):
dbs = dbe.OpenDatabase("C:TestDB.accdb")

After scouring the net, I tried this:

'dbs = dbe.OpenDatabase("C:TestDB.accdb", False, False, "MSAccess;")

but it failed with 'could not find installable ISAM'.

Is there anything else I can try?

I've got an Access 2007 db with a form (frmEdit), on which there is a subform (subMain), whose record source is "SELECT * FROM tblMain;".

frmEdit is intended to allow the use to filter the results and the fields (columns) displayed in subMain, and to allow them editing of the entries displayed. This part I've accomplished with a series of unbound controls. I've also added several bound controls to display the active record. It looks quite a lot like a split form.

But I also want subMain and the bound controls to mirror one another (like in a split form). So when the "FirstName" field of Jane Smith's record is selected in subMain, I want the bound controls to display Jane's record and for the focus to be set to the txtFirstName text box. Conversely, if I select txtLastName in the bound controls, I want the "LastName" field in Jane's record to be highlighted in subMain.

I've tried just using a split form, but I've decided I don't like split forms. I'm sure many of you agree.

The great boblarson has, I think, brought me within arm's reach of achieving the subform functionality I seek, with this forum post (last post in thread). I can't quite get there, though (I'm still very much a VBA novice). Below is what I've done and the issues I've been encountering.

I put bob's code (which I still don't quite fully understand) into Private Sub Form_Current() in my Form_subMain Module, and for the string ("[IDFieldNameHere]=" & Me!IDFieldHere) I've used Public Function BuildFilter() from my Form_frmEdit Module, but I've removed the "WHERE ".

Bob's code (with my edits):

	Code:
	Dim rst As DAO.Recordset
Set rst = Me.Parent.RecordsetClone

Dim BuildFilter2 As String
Set BuildFilter2 = CStr(Form_frmEdit.BuildFilter)

If Left(BuildFilter2, 6) = "WHERE " Then
   BuildFilter2 = Right(BuildFilter2, Len(BuildFilter2) - 6)
End If

rst.FindFirst BuildFilter2

If rst.NoMatch Then 
   msgbox "Error! Contact your IT Representative", vbExclamation, "No Match Found"
Else
   Me.Parent.Bookmark = rst.Bookmark
End If
 
rst.Close
Set rst = Nothing

My (abridged) code:

	Code:
	Private Sub InstantSearch()

'Update subMain record source
    Me.subMain.Form.RecordSource = "SELECT * FROM tblMain " & BuildFilter
    
'Requery subMain
    Me.subMain.Requery

End Sub
'________________________________________________________________

Public Function BuildFilter() As Variant

Dim varWhere As Variant: varWhere = Null

'...

    'Build date parameters into varWhere
    If Me.startDateBefore > "" Then
        varWhere = varWhere & "[StartDate] = #" & Me.startDateAfter & "# And "
    End If

'...

    'Tidy and finish varWhere
    If IsNull(varWhere) Then
        'Do nothing
    Else
        If Right(varWhere, 5) = " And " Then
            varWhere = Left(varWhere, Len(varWhere) - 5)
            varWhere = "WHERE " & varWhere
        End If
    End If

    BuildFilter = varWhere
    
End Function

I'm getting Compile error: Object required when I try to open frmEdit. "BuildFilter2 =" is highlighted (under "Dim BuildFilter2 As String"). I wonder if the problem is that Microsoft DAO 3.6 Object Library isn't added as a reference. When I try to add it, though, I get "Name conflicts with existing module, project, or object library." The other references I have checked off are "Visual Basic For Applications," "Microsoft Access 12.0 Object Library," "OLE Automation," and "Microsoft Office 12.0 Access database engine Object Library."

Bob's thread post: http://www.accessforums.net/forms/sp...ing-20194.html

Hi

I would like to find an efficient and effective way of retrieving text from webpages using VBA in Access, basically a web query. I know this can be done in Excel and have experimented with the code below to do this in Access. I really just need to get the raw data into a file so I can link/import and manipulate it further as needed. If this is dumped as one field that is okay for what I'm after.

The code works fine if you want to know the script behind the webpage etc. but I'm after retrieving data from the page as a user would see it or at least including this.

For example, if I wanted to automatically retrieve prices from a webpage I am after the product description and price, not a load of html code. I have tried various different file formats and at the moment 'xls' is the closest.

Does anyone know of a better method to retrieve just the text as is?

Many thanks

-----------------------------------------------------------------------

'The only ADO or DAO reference present must be "Microsoft DAO 3.6 Object Library"
Option Compare Database
Option Explicit
'Declare function from URLMON.DLL library, installed with Internet Explorer
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Function GetWeb()
Dim PageAddress As String
Dim PageDownLoad As Long
PageAddress = "http://www.access-programmers.co.uk/...ad.php?t=73744"
PageDownLoad = URLDownloadToFile(0, PageAddress, "C:test.xls", 0, 0)

End Function

Hi Forum Members,

I want to ask how can I list all standard Data Types, Classes, Collections, and Controls which are loaded currently in a VBA IDE session using VBA CODE (programmatically). I need for developing an Add-In for MS Access.

For clarification, from References you added Microsoft DAO 3.6 Object Library, then you added Microsoft Windows Common Controls 6.0. I should get all the primitives data types (Integer, Byte, Boolean, ...), all classes exist in DAO Library, all standard controls (Label, TextBox, ...), and all controls exist in Microsoft Windows Common Controls 6.0.

For those who know MZTools I want exactly like what MZTools give in its Comboboxes when you try to add a Procedure.

I spent lots of time in the net for a clue but am result less. Many asked the same question but there were no good answer.

All
I need to run this routine without adding the reference to use of Excel 12.0. This will be running on machines with Office 2007 as well as Office 2003 (Access2007Runtime)
The routine throws a Compile Error: User-defined type not defined at "Dim objXLBook As Excel.Workbook"

Any ideas on how to modify this code?


	Code:
	Private Sub btnOutToExec_Click()

On Error GoTo ExecHandleError

Dim objXLApp As Object
Set objXLApp = CreateObject("Excel.Application")
Dim objXLBook As Excel.Workbook

Dim db As DAO.Database

    Set db = CurrentDb

    conPath = GetPath(db.Name)

    'delete the spreadsheet
    Kill conPath & "MySpreadsheet.xls"

    ' create a workbook from the template
    Set objXLApp = New Excel.Application
    Set objXLBook = objXLApp.Workbooks.Open(conPath & "GL Executive and Operational TEMPLATE.xlt")
    'objXLApp.Visible = True

    objXLBook.SaveAs (conPath & "GLT Executive and Operational Report.xls")
    objXLBook.Close

    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "ExecReportData", conPath & "GL Executive and Operational
Report.xls", True


MsgBox "Done!" & vbCrLf & vbCrLf & "Look in the directory" & vbCrLf & vbCrLf & "where the application sits for ""GL Executive
and Operational Report.xls"""

ProcDone:
    On Error Resume Next

    ' Let's clean up our act
    Set qdf = Nothing
    Set db = Nothing
    Set rs = Nothing
    Set objResultsSheet = Nothing
    Set objXLBook = Nothing
    Set objXLApp = Nothing



ExitHere:
    Exit Sub
ExecHandleError:
    Select Case Err.Number
        Case 3265
            Resume Next
        Case 1004
            Set objXLBook = objXLApp.Workbooks.Open(conPath & "Generic1.xlt")
            Resume Next
        Case 53
            Resume Next
        Case 75
            Resume Next
        Case Else
            MsgBox Err.Description, vbExclamation, _
             "Error " & Err.Number
    End Select
    Resume ProcDone
End Sub




Not finding an answer? Try a Google search.