too few paramaters in my INSERT INTO

W

worksfire1

I had this working when I only coded it to insert 2 fields from my list
boxes. I simply added the other 4 fields that are in my list box and now I
am getting a message:
"Too few paramaters. Expected 1"

Here is my code with 6 fields I want to insert into tblTest:
db.Execute "INSERT INTO tblTest " & "([Oracle#],[DOS],[KCI
Item],[Cycle#],[Order Type],[Oracle ID])" & " VALUES(" &
ctl.ItemData(varItem) & "," & ctl.Column(2, varItem) & ",'" & ctl.Column(3,
varItem) & "'," & ctl.Column(4, varItem) & ",'" & ctl.Column(5, varItem) &
"'," & ctl.Column(6, varItem) & ")"
 
D

Douglas J. Steele

As written, Oracle#, DOS, Cycle# and Oracle ID must be numeric fields, and
KCI Item and Order Type must be text fields. Is that correct?
 
W

worksfire1

No - I am afraid my use of single quotes and quotes are not understood by me.
Cycle #, Oracle ID are the numeric fields.
Oracle#,DOS,KCI Item, and Order Type are text.
How should I have this written?

Douglas J. Steele said:
As written, Oracle#, DOS, Cycle# and Oracle ID must be numeric fields, and
KCI Item and Order Type must be text fields. Is that correct?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


worksfire1 said:
I had this working when I only coded it to insert 2 fields from my list
boxes. I simply added the other 4 fields that are in my list box and now
I
am getting a message:
"Too few paramaters. Expected 1"

Here is my code with 6 fields I want to insert into tblTest:
db.Execute "INSERT INTO tblTest " & "([Oracle#],[DOS],[KCI
Item],[Cycle#],[Order Type],[Oracle ID])" & " VALUES(" &
ctl.ItemData(varItem) & "," & ctl.Column(2, varItem) & ",'" &
ctl.Column(3,
varItem) & "'," & ctl.Column(4, varItem) & ",'" & ctl.Column(5, varItem) &
"'," & ctl.Column(6, varItem) & ")"
 
W

worksfire1

It wasn't my quotes necessarily after all. I did not know that
column(2,varitem) is really column 3 and column(4,varitem) is colum 3, etc.

That was throwing me off big time when I was trying to set the properties of
the fields in the table I wanted to append to. And got me all flustered.

I believe single quotes makes nice for text fields. and no quotes for
numeric.
Is that right?

Douglas J. Steele said:
As written, Oracle#, DOS, Cycle# and Oracle ID must be numeric fields, and
KCI Item and Order Type must be text fields. Is that correct?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


worksfire1 said:
I had this working when I only coded it to insert 2 fields from my list
boxes. I simply added the other 4 fields that are in my list box and now
I
am getting a message:
"Too few paramaters. Expected 1"

Here is my code with 6 fields I want to insert into tblTest:
db.Execute "INSERT INTO tblTest " & "([Oracle#],[DOS],[KCI
Item],[Cycle#],[Order Type],[Oracle ID])" & " VALUES(" &
ctl.ItemData(varItem) & "," & ctl.Column(2, varItem) & ",'" &
ctl.Column(3,
varItem) & "'," & ctl.Column(4, varItem) & ",'" & ctl.Column(5, varItem) &
"'," & ctl.Column(6, varItem) & ")"
 
D

Douglas J. Steele

As you've found, the Column collection starts numbering at 0, not 1.

Yes, you'd use ' for text fields (provided the text doesn't contain any
single quotes or apostrophes), no quotes for numeric fields, and # for
dates.

If the text does contain single quotes or apostrophes, you can use
Replace(YourTextValue, "'", "''"), rather than simply YourTextValue.
Exagerated for clarity, that's Replace(YourTextValue, " ' ", " ' ' ")

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


worksfire1 said:
It wasn't my quotes necessarily after all. I did not know that
column(2,varitem) is really column 3 and column(4,varitem) is colum 3,
etc.

That was throwing me off big time when I was trying to set the properties
of
the fields in the table I wanted to append to. And got me all flustered.

I believe single quotes makes nice for text fields. and no quotes for
numeric.
Is that right?

Douglas J. Steele said:
As written, Oracle#, DOS, Cycle# and Oracle ID must be numeric fields,
and
KCI Item and Order Type must be text fields. Is that correct?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


worksfire1 said:
I had this working when I only coded it to insert 2 fields from my list
boxes. I simply added the other 4 fields that are in my list box and
now
I
am getting a message:
"Too few paramaters. Expected 1"

Here is my code with 6 fields I want to insert into tblTest:
db.Execute "INSERT INTO tblTest " & "([Oracle#],[DOS],[KCI
Item],[Cycle#],[Order Type],[Oracle ID])" & " VALUES(" &
ctl.ItemData(varItem) & "," & ctl.Column(2, varItem) & ",'" &
ctl.Column(3,
varItem) & "'," & ctl.Column(4, varItem) & ",'" & ctl.Column(5,
varItem) &
"'," & ctl.Column(6, varItem) & ")"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top