Re: Too few parameters. Expected 1.
- From: "BruceM" <bamoob@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 5 Jan 2006 15:14:42 -0500
I realize that single quotes inside double quotes are valid, but I also know
I have had problems getting them to work as expected. It's difficult enough
for me to figure out three or four double quotes strung together without
compounding the confusion by trying to add a literal quote.
As for the parentheses, s is defined as a string, but the string starts with
a parentheses. I would have thought that if the string is being used for
the Execute method, the string needs to start with a quote and the
parentheses be left out. I freely admit I am unfamiliar with the Execute
method (and could find no help whatever in Help), but a string starting with
a parentheses just didn't look right to me. I would have expected the
parentheses to be part of the Execute method, and the string to replace what
comes between the parentheses.
Perhaps if I had a clearer idea of what was being attempted I would have
either avoided jumping in or would have provided something less speculative.
But thanks for your observations. I am learning a bit more each day.
"Klatuu" <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E5CEFD10-12E4-4521-A6B6-5C07919AD2BB@xxxxxxxxxxxxxxxx
> Using single qoutes inside double qoutes for SQL strings is perfectly
> valid.
> The parentheses are for the Execute() method, also valid.
> Basically, I don't see an syntax error. The parameter error in this case
> means that one of the fields identified in the VALUES list either does not
> exist or is misspelled. I am not positive there is no syntax error, but I
> don't see it.
>
> "BruceM" wrote:
>
>> I don't think there should be a parentheses before the first double quote
>> or
>> after the last one. If you are adding fields to the string you need to
>> insert a double quote to end the literal text before you insert the field
>> name. If you are adding two fields to the string you need to concatenate
>> them together:
>> Me.ship_num & " " & Me.ship_ref will give you the field values for
>> ship_num
>> and ship_ref with a space between them, assuming that ship_num and
>> ship_ref
>> are fields in the record source.
>> Which brings me to something that puzzles me: you said this code is part
>> of
>> a query, but the string would seem to be part of VBA code, which means it
>> is
>> associated with a form or report. How does the object in which the code
>> appears fit into the picture? Where in the query were you trying to
>> place
>> the code originally?
>> Also, there are some single quotes that I take it are supposed to be part
>> of
>> the string, but they could be confounding things. When I need a literal
>> quote or apostrophe to appear I tend to use chr(34) and chr(39):
>>
>> "#, " & chr(39) should give you a number sign, a comma, a space, and an
>> apostrophe.
>>
>> Remember, that is only if you need a quote mark or apostrophe in the text
>> string, not for the quotes marks that surround literal text values.
>>
>>
>>
>> "Jarryd" <j@xxx> wrote in message
>> news:eUJ317fEGHA.3200@xxxxxxxxxxxxxxxxxxxxxxx
>> > Hi TC,
>> >
>> > I did that.
>> >
>> > Dim s As String
>> > s = ("INSERT INTO BIll ([bill].[pickup_dt], Inv_num, [bill].[Inv_dt],
>> > ship_num, ship_ref_1, net_chg, fuel_net_chg, VAT, Consignee_Name,
>> > Consignee_City, ship_ref_2)" _
>> > & "VALUES( #" & pck_dt & "#, '" & Inv_num & "', #" & inv_dt & "#, '" &
>> > ship_num & "', '" & ship_r_1 & "', " & nchg & ", " & nfuel & ", " & VAT
>> > &
>> > ", " & con_nm & ", " & con_cty & ", '" & dept & "');")
>> > Debug.Print s '<==
>> >
>> > It didn't do anything... at all. What does it mean?
>> >
>> > TIA,
>> >
>> > Jarryd
>> > "TC" <gg.20.keen4some@xxxxxxxxxxxxxxx> wrote in message
>> > news:1136466440.926524.22550@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> >> Jarryd, it's hard to wade through actual code, when there's a simpler
>> >> way to see what's happening. Instead of putting the SQL string
>> >> directly
>> >> into the Execute call, store it into a string variable first. Then you
>> >> can print it to the debug window, which usually makes it easier to see
>> >> what is actually being executed:
>> >>
>> >> dim s as string
>> >> s = "INSERT INTO etc. etc. etc.
>> >> debug.print s ' <==
>> >> db.execute s
>> >>
>> >> Then look at the outpout in the debug window.
>> >>
>> >> My bet is, a string quote error :-)
>> >>
>> >> HTH,
>> >> TC [MVP Access]
>> >>
>> >
>> >
>>
>>
>>
.
- Follow-Ups:
- Re: Too few parameters. Expected 1.
- From: Klatuu
- Re: Too few parameters. Expected 1.
- References:
- Too few parameters. Expected 1.
- From: Jarryd
- Re: Too few parameters. Expected 1.
- From: TC
- Re: Too few parameters. Expected 1.
- From: Jarryd
- Re: Too few parameters. Expected 1.
- From: BruceM
- Re: Too few parameters. Expected 1.
- From: Klatuu
- Too few parameters. Expected 1.
- Prev by Date: Re: What happens when data in control is updated
- Next by Date: Re: Append query
- Previous by thread: Re: Too few parameters. Expected 1.
- Next by thread: Re: Too few parameters. Expected 1.
- Index(es):
Relevant Pages
|