Advertisement

02.21.2008 at 08:15AM PST, ID: 23181541
[x]
Attachment Details

Error on export, "Too Few Parameters, Expected 1"

Asked by jlcannon in Access Reports, Microsoft Access Database

Tags: Microsoft, Access, 2003

I have an export that works in another database and so I figured i could use it in my current project so I did the copy and paste and then just edited the areas i thought needed changed but now when I run it, I get the error, "Too Few Parameters, Expected 1"... can anyone help?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
 
   Dim stDocName As String
'new code starts here
    Dim xlApp As Object
    Dim xlwb As Object
    Dim xlws As Excel.Worksheet
    Dim xlrng As Excel.Range
    Dim rs As DAO.Recordset
    Dim strSQL As String
'End New Code
 
 
If Me.StartDate = "" Or IsNull(Me.StartDate) Then
    MsgBox "You must supply a starting date."
    Me.StartDate.SetFocus
    Exit Sub
End If
If Me.EndDate = "" Or IsNull(Me.EndDate) Then
    MsgBox "You must supply a ending date."
    Me.EndDate.SetFocus
    Exit Sub
End If
If Not (IsDate(Me.StartDate)) Then
    MsgBox "Starting Date is not in a date format."
    Me.StartDate.SetFocus
    Exit Sub
End If
If Not (IsDate(Me.EndDate)) Then
    MsgBox "Ending Date is not in a date format."
    Me.EndDate.SetFocus
    Exit Sub
End If
'If Me.Company = "" Or IsNull(Me.Company) Then
    'MsgBox "You must select a company."
    'Me.Company.SetFocus
    'Exit Sub
'End If
 
 
    stDocName = "rptMSFinfo"
    DoCmd.OpenReport stDocName, acPreview
    Set db = CurrentDb
'New Code Here
Set db = CurrentDb
strSQL = "Select * from qryMSFinfo;"
Set rs = CurrentDb.OpenRecordset(strSQL)
Set xlApp = CreateObject("Excel.Application")
Set xlwb = xlApp.Workbooks.Open("C:\test\MSF.xls", True)
'This is optional
xlApp.Visible = "True"
 
    'Delete all data in template before moving data in
    Set xlws = xlwb.Worksheets("actual")
    xlws.Rows("4:65536").ClearContents
    xlws.Rows("4:65536").ClearFormats
    With xlws
        .Range("A4").CopyFromRecordset rs            'Copies the recordset into the worksheet
    End With
'End New Code
    
 
 
 
Exit_Command5_Click:
    Exit Sub
 
Err_Command5_Click:
    MsgBox Err.Description
    Resume Exit_Command5_Click
    
End Sub
 
 
---here is the query that it uses:
SELECT T_EVC_UE.[Event#], T_EVC_UE.[Event Date & Local Time], T_EVC_UE.Site, T_EVC_UE.[Description of Event], T_EVC_UE.[Summary of Investigation], tblManagementSystemFailures.MSFID, tblManagementSystemFailures.MSF, T_EVC_UE.ProcessArea1, T_EVC_UE.[1st Cause], T_EVC_UE.[2nd Cause], T_EVC_UE.[3rd Cause], T_EVC_UE.[Site RE Contact]
FROM T_EVC_UE INNER JOIN tblManagementSystemFailures ON T_EVC_UE.[Event#] = tblManagementSystemFailures.[Event#]
WHERE (((T_EVC_UE.[Event Date & Local Time]) Between GetStartDate() And GetEndDate()) AND ((T_EVC_UE.Site)= Forms!frmMSFRpt!Site Or IsNull(Forms!frmMSFRpt!Site)))
ORDER BY T_EVC_UE.[Event#];
[+][-]02.21.2008 at 08:19AM PST, ID: 20949167

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 08:21AM PST, ID: 20949201

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 08:48AM PST, ID: 20949484

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 08:51AM PST, ID: 20949508

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 09:47AM PST, ID: 20950020

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.21.2008 at 05:12PM PST, ID: 20953753

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Reports, Microsoft Access Database
Tags: Microsoft, Access, 2003
Sign Up Now!
Solution Provided By: boag2000
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628