Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Posts
    2

    Unanswered: Run time error 3061 - Too few parameters

    Hi! I've got a little problem here.

    In my database I have a number of queries, including some "core" queries, which other queries and forms are picking data from. These queries use parameters from several forms.

    Until now, I've been creating a parameter form that pops up before the queries are run, and closes afterwards. This form is fed with all the necessary parameters for the "core" queries before it "gives them away" to the queries.

    But to make things a little more elegant (and faster), I thought about the possibility of feeding the queries with parameters from the code, and not having to have the parameter form pop up every time I wanted to open a result form. But this didn't seem to be very easy.

    To make things easy, I've simplified the query so that there is only one parameter. The error still occurs, though...

    The query's SQL looks like this:

    PARAMETERS Fase Text ( 255 );
    SELECT [Historiske data].*, Anlegg.Anleggsnavn, Anlegg.HK, Anlegg.DK, Anlegg.DDK, Anlegg.DDDK, [Historiske data].Fase
    FROM Anlegg INNER JOIN [Historiske data] ON Anlegg.[Kostra prosjekt] = [Historiske data].[Kostra prosjekt]
    WHERE ((([Historiske data].Fase) Like [fase] & "*"));


    The code is like this:

    CurrentDb.QueryDefs("QryKjerneHistData").Parameter s!Fase = Fase
    CurrentDb.QueryDefs("QryKjerneHistData").OpenRecor dset
    DoCmd.OpenForm ("FrmAnlegg") ' This form uses the query

    At the second line the error comes up.


    The same problem occurs in other queries, it's not only this one. I have no idea what I'm doing wrong...

    I know I can use the "DoCmd.RunSQL"-command, but that will make things a lot less tidy....

    Any help will be highly appreciated :-)

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Access cannot find one (or more) of the columns ... Verify that there are no typos or cchanges to the underlying tables.
    Back to Access ... ADO is not the way to go for speed ...

  3. #3
    Join Date
    Mar 2004
    Location
    Slovenia
    Posts
    56

    3061 - i hate this number too ;)

    PARAMETERS Fase Text ( 255 );
    SELECT [Historiske data].*, Anlegg.Anleggsnavn, Anlegg.HK, Anlegg.DK, Anlegg.DDK, Anlegg.DDDK, [Historiske data].Fase
    FROM Anlegg INNER JOIN [Historiske data] ON Anlegg.[Kostra prosjekt] = [Historiske data].[Kostra prosjekt]
    WHERE ((([Historiske data].Fase) Like [fase] & "*"));

    try without parameters

    if variable is text then you have to enclose it with sign '
    variable = "somestring"
    variable = "'" & variable & "'"

    if the variable is only start of the string then
    variable = "'" & variable & "*'"

    SELECT [Historiske data].*, Anlegg.Anleggsnavn, Anlegg.HK, Anlegg.DK, Anlegg.DDK, Anlegg.DDDK, [Historiske data].Fase
    FROM Anlegg INNER JOIN [Historiske data] ON Anlegg.[Kostra prosjekt] = [Historiske data].[Kostra prosjekt]
    WHERE ((([Historiske data].Fase) Like " & variable & " ));"

    put a msgbox at the end:

    it should write sth like:
    WHERE ((([Historiske data].Fase) Like 'somestring*' ));"
    Back to the basics...

  4. #4
    Join Date
    Jul 2004
    Posts
    2
    Quote Originally Posted by mp218
    Access cannot find one (or more) of the columns ... Verify that there are no typos or cchanges to the underlying tables.
    I'm sure about that.

    Quote Originally Posted by mp218
    PARAMETERS Fase Text ( 255 );
    SELECT [Historiske data].*, Anlegg.Anleggsnavn, Anlegg.HK, Anlegg.DK, Anlegg.DDK, Anlegg.DDDK, [Historiske data].Fase
    FROM Anlegg INNER JOIN [Historiske data] ON Anlegg.[Kostra prosjekt] = [Historiske data].[Kostra prosjekt]
    WHERE ((([Historiske data].Fase) Like [fase] & "*"));

    try without parameters
    I've tried that. Then I only get a "Run time error 3265. The element does not exist in the collection" (or something like that; I've got the Norwegian version) when running the first line

    CurrentDb.QueryDefs("QryKjerneHistData").Parameter s("Fase") = Fase[/QUOTE]

    I've tried that, same result

    [QUOTE=mp218]if variable is text then you have to enclose it with sign '
    variable = "somestring"
    variable = "'" & variable & "'"

    Quote Originally Posted by mp218
    if the variable is only start of the string then
    variable = "'" & variable & "*'"

    SELECT [Historiske data].*, Anlegg.Anleggsnavn, Anlegg.HK, Anlegg.DK, Anlegg.DDK, Anlegg.DDDK, [Historiske data].Fase
    FROM Anlegg INNER JOIN [Historiske data] ON Anlegg.[Kostra prosjekt] = [Historiske data].[Kostra prosjekt]
    WHERE ((([Historiske data].Fase) Like " & variable & " ));"

    put a msgbox at the end:

    it should write sth like:
    WHERE ((([Historiske data].Fase) Like 'somestring*' ));"
    It seems to me that the problem is that the parameters aren't "saved". I've tried with this:

    CurrentDb.QueryDefs("QryKjerneHistData").Parameter s(0) = "PNr"
    MsgBox CurrentDb.QueryDefs("QryKjerneHistData").Parameter s(0)

    and the msgbox is blank...

    I'm still confused... :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •