Too few parameters

harrisw

Registered User.
Local time
Today, 02:20
Joined
Mar 27, 2001
Messages
131
Have the code belowPublic Sub MultiDirectors()

Dim DBase As Database
Dim rsSet As Recordset
Dim rsResults As Recordset
Dim qrydef As New QueryDef

Set DBase = CurrentDb
Set rsSet = DBase.OpenRecordset("directors")
Set rsResults = DBase.OpenRecordset("results")

Set qrydef = DBase.CreateQueryDef("", "INSERT INTO Results SELECT " & rsSet![Business URN] _
& " FROM Directors GROUP BY " & rsSet![Business URN] & "")


qrydef.Execute

End Sub

I get a "too few paramters" error. All the fields and tables are spelt correctly. Don't know what else to check......

Any Ideas
 
harrisw,

Set qrydef = DBase.CreateQueryDef("", "INSERT INTO Results SELECT " & rsSet![Business URN] _
& " FROM Directors GROUP BY " & rsSet![Business URN] & "")

It is not clear what you're doing here. You are generating
something like:

Insert Into Results
Select xxxx
From Directors
Group by xxxx

Where xxxx is the contents of the first (random) record in
your recordset. The contents of [Business URN] is probably
not a valid field Name.

You would seem to need:

Insert Into Results (a, b, c)
Select a, b, c
From Directors
Group by a

But with the Group By that would error out.

Need more info ...

Wayne
 
I have a list of ids in the directors table.

I want to create the results table that has the same ids but keeps them unique ie no duplicates.

The directors table will have duplicate id's
 
By chance I changed the code to

Set qrydef = DBase.CreateQueryDef("", "INSERT INTO Results SELECT directors.[Business URN] FROM Directors GROUP BY directors.[Business URN] ) "

and it worked.

thanks again.
 

Users who are viewing this thread

Back
Top Bottom