sonaljain123
Registered User.
- Local time
- Today, 17:04
- Joined
- Jul 6, 2011
- Messages
- 68
Hi, I am trying to run the following code in VB in MS Access to basically run a query and I am getting a syntax error saying
"Syntax error (missing operator) in query expression 'HD_GL_ACCT_BALANCE.DATEFROM HD_GL_ACCT_BALANCE INNER JOIN MAP_BALC_DESC ON HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO = MAP_BALC_DESC.BAL_IDWHERE(((HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO)= BALCFA) AND ((HD_GL_ACCT_BALANCE.DATE) In (" & getDateFilter & "))))"
My actual code is as follows and the same query works perfectly fine in SQL:
Private Sub Command25_Click()
Dim stDocName As String
Dim iQuery As String
Dim dbsCurrent As Database
Dim qryTest As QueryDef
On Error GoTo Err_Daily_Balance_Sheet_View_Click
iQuerySelect = "SELECT HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO AS Account_Number, MAP_BALC_DESC.BAL_DESC AS Description, HD_GL_ACCT_BALANCE.GL_BALANCE, HD_GL_ACCT_BALANCE.DATE"
iQueryFrom = "FROM HD_GL_ACCT_BALANCE INNER JOIN MAP_BALC_DESC ON HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO = MAP_BALC_DESC.BAL_ID"
iQueryWhere = "WHERE (((HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO)= BALCFA) AND ((HD_GL_ACCT_BALANCE.DATE) In (" & getDateFilter & "))))"
iQuery = iQuerySelect & iQueryFrom & iQueryWhere
Debug.Print iQuery
Set dbsCurrent = CurrentDb
Set qryTest = dbsCurrent.QueryDefs("Daily_BS_View_Query")
Can anyone spot any error in the same? Thanks in advance.
"Syntax error (missing operator) in query expression 'HD_GL_ACCT_BALANCE.DATEFROM HD_GL_ACCT_BALANCE INNER JOIN MAP_BALC_DESC ON HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO = MAP_BALC_DESC.BAL_IDWHERE(((HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO)= BALCFA) AND ((HD_GL_ACCT_BALANCE.DATE) In (" & getDateFilter & "))))"
My actual code is as follows and the same query works perfectly fine in SQL:
Private Sub Command25_Click()
Dim stDocName As String
Dim iQuery As String
Dim dbsCurrent As Database
Dim qryTest As QueryDef
On Error GoTo Err_Daily_Balance_Sheet_View_Click
iQuerySelect = "SELECT HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO AS Account_Number, MAP_BALC_DESC.BAL_DESC AS Description, HD_GL_ACCT_BALANCE.GL_BALANCE, HD_GL_ACCT_BALANCE.DATE"
iQueryFrom = "FROM HD_GL_ACCT_BALANCE INNER JOIN MAP_BALC_DESC ON HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO = MAP_BALC_DESC.BAL_ID"
iQueryWhere = "WHERE (((HD_GL_ACCT_BALANCE.GL_ACCOUNT_NO)= BALCFA) AND ((HD_GL_ACCT_BALANCE.DATE) In (" & getDateFilter & "))))"
iQuery = iQuerySelect & iQueryFrom & iQueryWhere
Debug.Print iQuery
Set dbsCurrent = CurrentDb
Set qryTest = dbsCurrent.QueryDefs("Daily_BS_View_Query")
Can anyone spot any error in the same? Thanks in advance.