Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Need help with transferring to Excel

Discussion in 'Information Technology' started by pokdbz, Jul 28, 2006.

  1. pokdbz

    Expand Collapse

    Here is my query that I am using which I want transferred:
    WHERE (((PHQ.SSN)=[Forms]![Form1]![SSN]));

    I am using this below to transfer items to an Excel sheet. Where I have the
    stars is where it is giving me an error. Here is the error:
    Runtime error 3061
    Too few parameters. Expected 1.

    Is there something I have to do different because this is a query?

    Dim objXL As Excel.Application
    Dim objWkb As Excel.Workbook
    Dim objSht As Excel.Worksheet
    Dim db As Database
    Dim rs As Recordset
    Dim intLastCol As Integer
    Const conMAX_ROWS = 20000
    Const conSHT_NAME = "PHQChartQuery"
    Const conWKB_NAME = "C:\PHQChart.xls"
    Set db = CurrentDb
    Set objXL = New Excel.Application
    Set rs = db.OpenRecordset("PHQChartQuery", dbOpenSnapshot)
    With objXL
    .Visible = True
    Set objWkb = .Workbooks.Open(conWKB_NAME)
    On Error Resume Next
    Set objSht = objWkb.Worksheets(conSHT_NAME)
    If Not Err.Number = 0 Then
    Set objSht = objWkb.Worksheets.Add
    objSht.Name = conSHT_NAME
    End If
    On Error GoTo 0
    intLastCol = objSht.UsedRange.Columns.Count
    With objSht
    .Range(.Cells(1, 1), .Cells(conMAX_ROWS, _
    .Range(.Cells(1, 1), _
    .Cells(1, rs.Fields.Count)).Font.Bold = True
    .Range("A2").CopyFromRecordset rs
    End With
    End With
    Set objSht = Nothing
    Set objWkb = Nothing
    Set objXL = Nothing
    Set rs = Nothing
    Set db = Nothing
  2. Loading...

    Similar Threads Forum Date
    Helping Education To The Needy Through Daswandh Hard Talk Apr 14, 2017
    Interracial And Interfaith Marriage, Help Needed To Confront/convince My Parents Love & Marriage Aug 16, 2016
    17 yr old Baljit needs your help Get Involved Aug 19, 2015
    Learn Punjabi Need help Language, Arts & Culture May 20, 2014
    United Sikhs From United Sikhs. Phillippines Needs Your Help Sikh Organisations Nov 22, 2013

Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     

Share This Page