PC Review


Reply
Thread Tools Rate Thread

Another recordset problem!

 
 
PayeDoc
Guest
Posts: n/a
 
      4th Mar 2010
Hello All

I had some help with a recordset problem recently (many thanks Stefan and
Daryl!), but now have another. I just get "Error 3135 Syntax error in JOIN
operation" with the following:

Set rsNIC = CurrentDb.OpenRecordset( _
"SELECT staffs.*, months.*, [NI tables 2010].*" & _
" FROM ((staffs RIGHT JOIN ([NI tables 2010] RIGHT JOIN months" & _
" ON [NI tables 2010].[NI letter] = staffs.[NI code])" & _
" ON [NI tables 2010].niSet = months.nicset)" & _
" WHERE (((months.[month name])='" & [Forms]![frm x main]![month
name] & "'));")

If anyone can help with this I'd be really grateful - as ever!!

Many thanks
Leslie Isacas



 
Reply With Quote
 
 
 
 
vanderghast
Guest
Posts: n/a
 
      4th Mar 2010
The part:

([NI tables 2010] RIGHT JOIN months" & _
" ON [NI tables 2010].[NI letter] = staffs.[NI code])"

sounds strange: you define a join on two tables... but ON another table, I
mean, why it is not:


([NI tables 2010] RIGHT JOIN months" & _
" ON [NI tables 2010].niSet = months.nicset)"


and then, introduces table staffs in another join:

....
" FROM ((staffs RIGHT JOIN ([NI tables 2010] RIGHT JOIN months" & _
" ON [NI tables 2010].niSet = months.nicset)" & _
" ON [NI tables 2010].[NI letter] = staffs.[NI code])" & _
....

Such join is ambiguous, though, and cannot be used as it is, with Jet. Make
a first query with:
SELECT * FROM [NI tables 2010] RIGHT JOIN months ON [NI tables 2010].niSet
= months.nicset

and use that saved query:


.....
" FROM staffs RIGHT JOIN savedQuery ON savedQuery.[NI letter] =
staffs.[NI code] " & _
.....


if that is really what you want.




Vanderghast, Access MVP



"PayeDoc" <(E-Mail Removed)> wrote in message
news:e8c%(E-Mail Removed)...
> Hello All
>
> I had some help with a recordset problem recently (many thanks Stefan and
> Daryl!), but now have another. I just get "Error 3135 Syntax error in JOIN
> operation" with the following:
>
> Set rsNIC = CurrentDb.OpenRecordset( _
> "SELECT staffs.*, months.*, [NI tables 2010].*" & _
> " FROM ((staffs RIGHT JOIN ([NI tables 2010] RIGHT JOIN months" & _
> " ON [NI tables 2010].[NI letter] = staffs.[NI code])" & _
> " ON [NI tables 2010].niSet = months.nicset)" & _
> " WHERE (((months.[month name])='" & [Forms]![frm x main]![month
> name] & "'));")
>
> If anyone can help with this I'd be really grateful - as ever!!
>
> Many thanks
> Leslie Isacas
>
>
>


 
Reply With Quote
 
PayeDoc
Guest
Posts: n/a
 
      4th Mar 2010
Hello Vanderghast

Many thanks for your reply.
Perhaps I should provide a little more info.

I had this, which works fine:
Set rs = CurrentDb.OpenRecordset( _
"SELECT staffs.*, [tax tables].*, [NI tables 2009].*, [SSP
tables].*, [SMP tables].* " & _
"FROM (([tax tables] RIGHT JOIN ([NI tables 2009] RIGHT JOIN staffs
" & _
"ON [NI tables 2009].[NI letter] = staffs.[NI code]) " & _
"ON [tax tables].set = staffs.taxset) LEFT JOIN [SSP tables] " & _
"ON staffs.[ssp set] = [SSP tables].[SSP set]) LEFT JOIN [SMP
tables] " & _
"ON staffs.[smp set] = [SMP tables].[SMP set];")

The problem is that I now need to pick up the data in [NI tables 2009] via a
join to the table [months] i.e. [NI tables 2010].niSet = months.nicset. This
is in addition to the join [NI tables 2009].[NI letter] = staffs.[NI code],
which is in the original recordset above. I still need the other fields from
[SSP tables], [SMP tables] and [tax tables] from the recordset above, but
thought it best to define a new recordset (rsNIC) for the [NI tables 2009]
values that are needed, and it's this new recordset that I'm now struggling
with. Would it be feasible/recommended instead to amend the original
recordset above, so that it picks up the the data in [NI tables 2009] using
the (new) link to the table [months]?

Hope this all makes sense!
Thanks again for your help.
Les



"vanderghast" <vanderghast@com> wrote in message
news:(E-Mail Removed)...
> The part:
>
> ([NI tables 2010] RIGHT JOIN months" & _
> " ON [NI tables 2010].[NI letter] = staffs.[NI code])"
>
> sounds strange: you define a join on two tables... but ON another table, I
> mean, why it is not:
>
>
> ([NI tables 2010] RIGHT JOIN months" & _
> " ON [NI tables 2010].niSet = months.nicset)"
>
>
> and then, introduces table staffs in another join:
>
> ...
> " FROM ((staffs RIGHT JOIN ([NI tables 2010] RIGHT JOIN months" &

_
> " ON [NI tables 2010].niSet = months.nicset)" & _
> " ON [NI tables 2010].[NI letter] = staffs.[NI code])" & _
> ...
>
> Such join is ambiguous, though, and cannot be used as it is, with Jet.

Make
> a first query with:
> SELECT * FROM [NI tables 2010] RIGHT JOIN months ON [NI tables

2010].niSet
> = months.nicset
>
> and use that saved query:
>
>
> ....
> " FROM staffs RIGHT JOIN savedQuery ON savedQuery.[NI letter] =
> staffs.[NI code] " & _
> ....
>
>
> if that is really what you want.
>
>
>
>
> Vanderghast, Access MVP
>
>
>
> "PayeDoc" <(E-Mail Removed)> wrote in message
> news:e8c%(E-Mail Removed)...
> > Hello All
> >
> > I had some help with a recordset problem recently (many thanks Stefan

and
> > Daryl!), but now have another. I just get "Error 3135 Syntax error in

JOIN
> > operation" with the following:
> >
> > Set rsNIC = CurrentDb.OpenRecordset( _
> > "SELECT staffs.*, months.*, [NI tables 2010].*" & _
> > " FROM ((staffs RIGHT JOIN ([NI tables 2010] RIGHT JOIN months" &

_
> > " ON [NI tables 2010].[NI letter] = staffs.[NI code])" & _
> > " ON [NI tables 2010].niSet = months.nicset)" & _
> > " WHERE (((months.[month name])='" & [Forms]![frm x main]![month
> > name] & "'));")
> >
> > If anyone can help with this I'd be really grateful - as ever!!
> >
> > Many thanks
> > Leslie Isacas
> >
> >
> >

>



 
Reply With Quote
 
Paolo
Guest
Posts: n/a
 
      4th Mar 2010
Hi PayeDoc,
try in this way
Set rsNIC = CurrentDb.OpenRecordset("SELECT staffs.*, months.*, [NI tables
2010].* FROM (staffs RIGHT JOIN [NI tables 2010] ON staffs.[NI code] = [NI
tables 2010].[NI letter]) RIGHT JOIN months ON [NI tables 2010].niSet =
months.nicset WHERE months.[month name]='" & [Forms]![frm x main]![month
name] & "'")

All on the same line.

HTH Paolo

"PayeDoc" wrote:

> Hello All
>
> I had some help with a recordset problem recently (many thanks Stefan and
> Daryl!), but now have another. I just get "Error 3135 Syntax error in JOIN
> operation" with the following:
>
> Set rsNIC = CurrentDb.OpenRecordset( _
> "SELECT staffs.*, months.*, [NI tables 2010].*" & _
> " FROM ((staffs RIGHT JOIN ([NI tables 2010] RIGHT JOIN months" & _
> " ON [NI tables 2010].[NI letter] = staffs.[NI code])" & _
> " ON [NI tables 2010].niSet = months.nicset)" & _
> " WHERE (((months.[month name])='" & [Forms]![frm x main]![month
> name] & "'));")
>
> If anyone can help with this I'd be really grateful - as ever!!
>
> Many thanks
> Leslie Isacas
>
>
>
> .
>

 
Reply With Quote
 
PayeDoc
Guest
Posts: n/a
 
      4th Mar 2010
Hello Paolo

That's it - no errors now!
Very many thanks for this.

Les



"Paolo" <(E-Mail Removed)> wrote in message
news:B56C5FE8-99CB-4EE6-BB5E-(E-Mail Removed)...
> Hi PayeDoc,
> try in this way
> Set rsNIC = CurrentDb.OpenRecordset("SELECT staffs.*, months.*, [NI tables
> 2010].* FROM (staffs RIGHT JOIN [NI tables 2010] ON staffs.[NI code] = [NI
> tables 2010].[NI letter]) RIGHT JOIN months ON [NI tables 2010].niSet =
> months.nicset WHERE months.[month name]='" & [Forms]![frm x main]![month
> name] & "'")
>
> All on the same line.
>
> HTH Paolo
>
> "PayeDoc" wrote:
>
> > Hello All
> >
> > I had some help with a recordset problem recently (many thanks Stefan

and
> > Daryl!), but now have another. I just get "Error 3135 Syntax error in

JOIN
> > operation" with the following:
> >
> > Set rsNIC = CurrentDb.OpenRecordset( _
> > "SELECT staffs.*, months.*, [NI tables 2010].*" & _
> > " FROM ((staffs RIGHT JOIN ([NI tables 2010] RIGHT JOIN months"

& _
> > " ON [NI tables 2010].[NI letter] = staffs.[NI code])" & _
> > " ON [NI tables 2010].niSet = months.nicset)" & _
> > " WHERE (((months.[month name])='" & [Forms]![frm x main]![month
> > name] & "'));")
> >
> > If anyone can help with this I'd be really grateful - as ever!!
> >
> > Many thanks
> > Leslie Isacas
> >
> >
> >
> > .
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with recordset ma Microsoft Access VBA Modules 2 16th May 2005 10:31 PM
problem with recordset ma Microsoft Access 2 16th May 2005 10:31 PM
Recordset problem =?Utf-8?B?YnV6eg==?= Microsoft Access VBA Modules 7 8th Dec 2004 11:49 PM
Problem with Set combobox.recordset = <adodb.recordset> Gijs Beukenoot Microsoft Access Form Coding 0 10th Nov 2004 06:22 PM
Re: !Recordset from a parameterized query, as the form's recordset. Problem on sorting... Savvoulidis Iordanis Microsoft Access Forms 0 24th Jun 2004 08:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:28 AM.