Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2007

Tip: Looking for answers? Try searching our database.

Foreign Currency in SQL statement

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Vikki - 30 May 2007 14:46 GMT
I am working on a database that is used in Germany. The code was written with
Regional settings in English (United States) and it worked fine.  The
Regional settings were then changed to German(Germany) and retested and it
all went south.  I had to "format" the dates because of the conversion
(thanks to a tip from this board), but it appears that I have the same type
of problem with the currency.  I am getting--

Run-time error ‘3075’:
Syntax error (comma) in query expression “Sum(sales.retail) Between 0,01 and
259,99.

The code is attached.  I assume I need to format the variables LowVal and
HighVal but what about the "Sum(sales.retail)?  Also, I am unsure at this
point what that format statement might look like, but I am still scouring the
help files/internet.   Can anyone help or at least point me in the proper
direction?

The code is:
Function TotConsCumm(ByVal LowVal As Currency, HighVal As Currency, InvMonth
As Integer, InvYear As Integer) As Long
 
 Dim BeginDate As Variant
 Dim EndDate As Variant
 Dim SQLString As String
 Dim intI As Integer
 Dim ConsCnt As Long
 
 ' Set the dbs to current database
   Set dbs = CurrentDb
 
 BeginDate = Format(DateValue(InvMonth & "/" & InvYear), "\#mm\/dd\/yyyy\#")
 EndDate = Format(LastOfMonth(InvMonth, InvYear), "\#mm\/dd\/yyyy\#")

 TotConsCumm = 0
 ConsCnt = 0
 
 ' Get the monthly sales data in one row each for consultants
 SQLString = "SELECT Sales.consultant_id, SUM(Sales.retail) FROM Sales " _
          & " WHERE Sales.transaction_date Between " + CStr(BeginDate) + "
AND " + CStr(EndDate) + " " _
          & " GROUP BY Sales.consultant_id" _
          & " HAVING SUM(Sales.retail) Between " + CStr(LowVal) + " AND " +
CStr(HighVal) + " "
 
 Set rstTemp = dbs.OpenRecordset(SQLString)
 
 If rstTemp.RecordCount > 0 Then
    rstTemp.MoveLast
    rstTemp.MoveFirst
    ConsCnt = rstTemp.RecordCount
    TotConsCumm = ConsCnt
 End If
RoyVidar - 30 May 2007 19:02 GMT
"Vikki" <Vikki@discussions.microsoft.com> wrote in message
<90EC7C07-4144-4BB8-90AE-1CD125BB6700@microsoft.com>:
> I am working on a database that is used in Germany. The code was
> written with  Regional settings in English (United States) and it
[quoted text clipped - 50 lines]
>      TotConsCumm = ConsCnt
>   End If

Jet operates with US dates and numbers, so you only need to format
the dates and numbers when concatenating them into a string passed
to Jet, so

...SUM(Sales.retail) Between " & Replace(CStr(LowVal), ",", ".") & ...

Signature

Roy-Vidar

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.