Updating data using VBA and SQL | | |
Hi All
My many thanks to DFS for helping me with my problem.
I had posted my problem a few weeks ago and DFS helped me out with the
code.
After having completed my other project, I got time to work on this
problem.
However, a part of this code is giving me a problem and I have a
feeling that either and a parenthesis is missing or there is an extra
parenthesis but I dont know which.
This is the code:
'LOOK FOR PRIOR MONTH PAYMENT
set rs1 = db.openRecordset("SELECT DISTINCT * FROM
tblTenantTransaction
WHERE TenantID = " & rs("TenantID") & " AND (datePart("m",[TransDate])
= " &
priorMonth & " and datePart("yyyy",[TransDate] = " & transYear & ");")
..
When I compile this code I get the following error msg
Compile Error
Syntax Error
My many thanks in advance to all of you for your help. | | | | re: Updating data using VBA and SQL
On 17 Jan 2004 01:57:49 -0800, hasanainf@yahoo.com (Hasanain F. Esmail) wrote:
[color=blue]
>priorMonth & " and datePart("yyyy",[TransDate] = " & transYear & ");")[/color]
Try
priorMonth & " and datePart("yyyy",[TransDate] = " & transYear & "));"
Wayne Gillespie
Gosford NSW Australia | | | | re: Updating data using VBA and SQL
There's no closing parenthesis to match the one that's opened after AND.
HTH
- Turtle
"Hasanain F. Esmail" <hasanainf@yahoo.com> wrote in message
news:27c08a7a.0401170157.451bcc91@posting.google.c om...[color=blue]
> Hi All
>
> My many thanks to DFS for helping me with my problem.
>
> I had posted my problem a few weeks ago and DFS helped me out with the
> code.
>
> After having completed my other project, I got time to work on this
> problem.
>
> However, a part of this code is giving me a problem and I have a
> feeling that either and a parenthesis is missing or there is an extra
> parenthesis but I dont know which.
>
>
> This is the code:
>
> 'LOOK FOR PRIOR MONTH PAYMENT
> set rs1 = db.openRecordset("SELECT DISTINCT * FROM
> tblTenantTransaction
> WHERE TenantID = " & rs("TenantID") & " AND (datePart("m",[TransDate])
> = " &
> priorMonth & " and datePart("yyyy",[TransDate] = " & transYear & ");")
> .
>
> When I compile this code I get the following error msg
> Compile Error
> Syntax Error
>
> My many thanks in advance to all of you for your help.[/color] | | | | re: Updating data using VBA and SQL
Thanks for your help.
Pardon my poor understandign of VBA and SQL
Can you please show me the systax
"MacDermott" <macdermott@nospam.com> wrote in message news:<AMaOb.11968$i4.4926@newsread1.news.atl.earth link.net>...[color=blue]
> There's no closing parenthesis to match the one that's opened after AND.
>
> HTH
> - Turtle
>
> "Hasanain F. Esmail" <hasanainf@yahoo.com> wrote in message
> news:27c08a7a.0401170157.451bcc91@posting.google.c om...[color=green]
> > Hi All
> >
> > My many thanks to DFS for helping me with my problem.
> >
> > I had posted my problem a few weeks ago and DFS helped me out with the
> > code.
> >
> > After having completed my other project, I got time to work on this
> > problem.
> >
> > However, a part of this code is giving me a problem and I have a
> > feeling that either and a parenthesis is missing or there is an extra
> > parenthesis but I dont know which.
> >
> >
> > This is the code:
> >
> > 'LOOK FOR PRIOR MONTH PAYMENT
> > set rs1 = db.openRecordset("SELECT DISTINCT * FROM
> > tblTenantTransaction
> > WHERE TenantID = " & rs("TenantID") & " AND (datePart("m",[TransDate])
> > = " &
> > priorMonth & " and datePart("yyyy",[TransDate] = " & transYear & ");")
> > .
> >
> > When I compile this code I get the following error msg
> > Compile Error
> > Syntax Error
> >
> > My many thanks in advance to all of you for your help.[/color][/color] | | | | re: Updating data using VBA and SQL
Below is probably the syntax you want.
But if you're going to work with this kind of thing, I'd really recommend
that you try to understand it.
It's not hard to count parentheses and see which kind you have more of.
HTH
- Turtle
set rs1 = db.openRecordset("SELECT DISTINCT * FROM
tblTenantTransaction
WHERE TenantID = " & rs("TenantID") & " AND (datePart("m",[TransDate])
= " &
priorMonth & " and datePart("yyyy",[TransDate] = " & transYear & "));")
"Hasanain F. Esmail" <hasanainf@yahoo.com> wrote in message
news:27c08a7a.0401172114.f0fa62c@posting.google.co m...[color=blue]
> Thanks for your help.
>
> Pardon my poor understandign of VBA and SQL
>
> Can you please show me the systax
>
>
> "MacDermott" <macdermott@nospam.com> wrote in message[/color]
news:<AMaOb.11968$i4.4926@newsread1.news.atl.earth link.net>...[color=blue][color=green]
> > There's no closing parenthesis to match the one that's opened after[/color][/color]
AND.[color=blue][color=green]
> >
> > HTH
> > - Turtle
> >
> > "Hasanain F. Esmail" <hasanainf@yahoo.com> wrote in message
> > news:27c08a7a.0401170157.451bcc91@posting.google.c om...[color=darkred]
> > > Hi All
> > >
> > > My many thanks to DFS for helping me with my problem.
> > >
> > > I had posted my problem a few weeks ago and DFS helped me out with the
> > > code.
> > >
> > > After having completed my other project, I got time to work on this
> > > problem.
> > >
> > > However, a part of this code is giving me a problem and I have a
> > > feeling that either and a parenthesis is missing or there is an extra
> > > parenthesis but I dont know which.
> > >
> > >
> > > This is the code:
> > >
> > > 'LOOK FOR PRIOR MONTH PAYMENT
> > > set rs1 = db.openRecordset("SELECT DISTINCT * FROM
> > > tblTenantTransaction
> > > WHERE TenantID = " & rs("TenantID") & " AND (datePart("m",[TransDate])
> > > = " &
> > > priorMonth & " and datePart("yyyy",[TransDate] = " & transYear & ");")
> > > .
> > >
> > > When I compile this code I get the following error msg
> > > Compile Error
> > > Syntax Error
> > >
> > > My many thanks in advance to all of you for your help.[/color][/color][/color] | | | | re: Updating data using VBA and SQL
Thank you very much
"MacDermott" <macdermott@nospam.com> wrote in message news:<FPAOb.13982$i4.8487@newsread1.news.atl.earth link.net>...[color=blue]
> Below is probably the syntax you want.
>
> But if you're going to work with this kind of thing, I'd really recommend
> that you try to understand it.
> It's not hard to count parentheses and see which kind you have more of.
>
> HTH
> - Turtle
>
> set rs1 = db.openRecordset("SELECT DISTINCT * FROM
> tblTenantTransaction
> WHERE TenantID = " & rs("TenantID") & " AND (datePart("m",[TransDate])
> = " &
> priorMonth & " and datePart("yyyy",[TransDate] = " & transYear & "));")
>
> "Hasanain F. Esmail" <hasanainf@yahoo.com> wrote in message
> news:27c08a7a.0401172114.f0fa62c@posting.google.co m...[color=green]
> > Thanks for your help.
> >
> > Pardon my poor understandign of VBA and SQL
> >
> > Can you please show me the systax
> >
> >
> > "MacDermott" <macdermott@nospam.com> wrote in message[/color]
> news:<AMaOb.11968$i4.4926@newsread1.news.atl.earth link.net>...[color=green][color=darkred]
> > > There's no closing parenthesis to match the one that's opened after[/color][/color]
> AND.[color=green][color=darkred]
> > >
> > > HTH
> > > - Turtle
> > >
> > > "Hasanain F. Esmail" <hasanainf@yahoo.com> wrote in message
> > > news:27c08a7a.0401170157.451bcc91@posting.google.c om...
> > > > Hi All
> > > >
> > > > My many thanks to DFS for helping me with my problem.
> > > >
> > > > I had posted my problem a few weeks ago and DFS helped me out with the
> > > > code.
> > > >
> > > > After having completed my other project, I got time to work on this
> > > > problem.
> > > >
> > > > However, a part of this code is giving me a problem and I have a
> > > > feeling that either and a parenthesis is missing or there is an extra
> > > > parenthesis but I dont know which.
> > > >
> > > >
> > > > This is the code:
> > > >
> > > > 'LOOK FOR PRIOR MONTH PAYMENT
> > > > set rs1 = db.openRecordset("SELECT DISTINCT * FROM
> > > > tblTenantTransaction
> > > > WHERE TenantID = " & rs("TenantID") & " AND (datePart("m",[TransDate])
> > > > = " &
> > > > priorMonth & " and datePart("yyyy",[TransDate] = " & transYear & ");")
> > > > .
> > > >
> > > > When I compile this code I get the following error msg
> > > > Compile Error
> > > > Syntax Error
> > > >
> > > > My many thanks in advance to all of you for your help.[/color][/color][/color] |  | Similar Microsoft Access / VBA bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|