Solved

Access VBA Error

Posted on 2013-01-15
2
124 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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now