Solved

Access VBA Error

Posted on 2013-01-15
2
127 Views
Last Modified: 2013-01-15
Hi all.

I get an error when my Access form gets to the following code. I know I have the date parameters portion wrong but I don't know how to get it to work. Any ideas?

Thank you in advance!

Set rsExcel = CurrentDb.OpenRecordset("SELECT [Division]+'-'+[CustomerNumber] AS Customer, InvHistoryHeader.InvoiceNumber, InvHistoryHeader.InvoiceDate,Invoice.TrackingID" & _
" FROM InvHistoryHeader INNER JOIN InvoiceTracking ON InvHistoryHeader.InvoiceNumber = InvoiceTracking.InvoiceNumber WHERE ((([Division]+'-'+[CustomerNumber])='" & Me.txtMASID & "') AND ((InvHistoryHeader.InvoiceDate)>= #" & Me.txtDate1 &"#  And " (InvHistoryHeader.InvoiceDate)<= #" & Me.txtDate2 &" # )) ORDER BY InvHistoryHeader.InvoiceDate")

Open in new window

0
Comment
Question by:printmedia
2 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38780460
Try this:

Dim strSQL as string
strSQL = "SELECT [Division]+'-'+[CustomerNumber] AS Customer, InvHistoryHeader.InvoiceNumber, InvHistoryHeader.InvoiceDate,Invoice.TrackingID " _
    & " FROM InvHistoryHeader INNER JOIN InvoiceTracking ON InvHistoryHeader.InvoiceNumber = InvoiceTracking.InvoiceNumber " _
    & " WHERE [Division]+'-'+[CustomerNumber] ='" & Me.txtMASID & "' " _
    & " AND InvHistoryHeader.InvoiceDate)>= #" & Me.txtDate1 & "#  And " _
    & " InvHistoryHeader.InvoiceDate <= #" & Me.txtDate2 & "#  ORDER BY InvHistoryHeader.InvoiceDate"
    


Set rsExcel = CurrentDb.OpenRecordset(strSQL)

Open in new window

0
 

Author Comment

by:printmedia
ID: 38780463
I've requested that this question be deleted for the following reason:

Solved it myself.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

839 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