Solved

Excel formatting from MSAccess

Posted on 2006-06-28
5
361 Views
Last Modified: 2008-01-09
I have a MSAccess utility that creates a XLS file and provides a bit of XLS formatting before I dump a recordset into it.

I and seeing an intermittent error in my code:

'Data Body Formatting
    With wksNew.Range("A6:R" & RecordCount)
        .Font.Size = 8
        .VerticalAlignment = xlVAlignCenter
        .BorderAround Weight:=xlThin
        .Borders(xlInsideVertical).Color = 15
        With .Borders(xlInsideHorizontal)
            .Weight = xlThin                          <----------Debug points to this line
            .Color = RGB(192, 192, 192)
        End With
    End With

Error:  Runtime Error '1004'  Unable to set the Weight Property of the Border Class.

I will get this error for a repeatable set of conditions related to the RecordSet, but NO error for a different set of conditions.  The actual data dump happens well after this command:


'Dump RecordSet to XLS

    Dim rs As DAO.Recordset
    Dim prm As DAO.Parameter
   
    Set qdf = CurrentDb.QueryDefs("DMSReport")
    'Evaluate the parameters from the form references
    For Each prm In qdf.Parameters
        prm.Value = Eval(prm.Name)
    Next
    Set rs = qdf.OpenRecordset(dbOpenSnapshot)
       
    With wksNew
        .Range("A7").CopyFromRecordset rs
    End With


Help??
0
Comment
Question by:markp99
5 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 17000994
Is it not better to apply formatting after u done CopyFromRecordset? just a thought

see this
http://support.microsoft.com/default.aspx?scid=kb;en-us;277577
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 17001250
**** Don't accept as Answer. Just curious*****
Hi Mark p
I'm wondering, if you create your code as a macro inside your spreadsheet and run it from there...is the border weight available within your workbook?

also, you might want to just line it out

.Borders(xlInsideHorizontal).Weight = xlThin                          <----------Debug points to this line
.Borders(xlInsideHorizontal).Color = RGB(192, 192, 192)
 
0
 

Author Comment

by:markp99
ID: 17001521
I found my problem, but seems strange:

There was an issue with my "RecordCount" variable (RecordCount = actualnorecords + 6).  I use this to format only the extent of the XLS sheet that will actually contain data.   In the error condition: RecordCount = 6, which is the Header of my XLS sheet which I formatted just before the problem section.

All is well now that I am getting a reliable RecordCount (there was a NULL vs "" issue in my DCount statement).
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 17893944
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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 Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

829 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