INSERT INTO question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this Code to INSERT INTO my Table named: BOM_EDIT_BuckUp with fields:
(Base_ID_B, Code_Sub_B, Part_ID_B, Description_B, QtyPer1_B, UOM_B)"
and I want to get them from my Table named: tbl_BOM with these records:
Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM tbl_BOM just a
"_B" was added in the BackUp table,

but I want to Insert them, if Base_ID (this Data is from tbl-BOM table) =
[ComboPI] (this is a combo that Filter Datas in the subForm, and are equal to
Base_ID)

I running this code in a Form named:BOM_PRINT and the SubForm where all
records are filtered is: QueryBOMsubform


could you please help...
=================================================
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B, Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM
tbl_BOM" & _
"WHERE Base_ID = ([ComboPI])"
DoCmd.SetWarnings True
=================================================
 
You've got a superfluous comma between UOM and FROM.

I'd also use

"WHERE Base_ID = " & Me.[ComboPI]

for the last line, assuming Base_ID is a numeric field. If it's text:

"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)
 
Hi Douglas..

I have corrected the comma and the code now is so:
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B, Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

but at the time to run it show a message error saying "
SYNTAX ERROR in FROM CLAUSE..

is something else wrong?

--
Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
You've got a superfluous comma between UOM and FROM.

I'd also use

"WHERE Base_ID = " & Me.[ComboPI]

for the last line, assuming Base_ID is a numeric field. If it's text:

"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


ldiaz said:
I have this Code to INSERT INTO my Table named: BOM_EDIT_BuckUp with fields:
(Base_ID_B, Code_Sub_B, Part_ID_B, Description_B, QtyPer1_B, UOM_B)"
and I want to get them from my Table named: tbl_BOM with these records:
Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM tbl_BOM just a
"_B" was added in the BackUp table,

but I want to Insert them, if Base_ID (this Data is from tbl-BOM table) =
[ComboPI] (this is a combo that Filter Datas in the subForm, and are equal to
Base_ID)

I running this code in a Form named:BOM_PRINT and the SubForm where all
records are filtered is: QueryBOMsubform


could you please help...
=================================================
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B, Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM
tbl_BOM" & _
"WHERE Base_ID = ([ComboPI])"
DoCmd.SetWarnings True
=================================================
 
You're missing a space between the closing parenthesis and the keyword
SELECT.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


ldiaz said:
Hi Douglas..

I have corrected the comma and the code now is so:
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B, Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

but at the time to run it show a message error saying "
SYNTAX ERROR in FROM CLAUSE..

is something else wrong?

--
Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
You've got a superfluous comma between UOM and FROM.

I'd also use

"WHERE Base_ID = " & Me.[ComboPI]

for the last line, assuming Base_ID is a numeric field. If it's text:

"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


ldiaz said:
I have this Code to INSERT INTO my Table named: BOM_EDIT_BuckUp with fields:
(Base_ID_B, Code_Sub_B, Part_ID_B, Description_B, QtyPer1_B, UOM_B)"
and I want to get them from my Table named: tbl_BOM with these records:
Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM tbl_BOM just a
"_B" was added in the BackUp table,

but I want to Insert them, if Base_ID (this Data is from tbl-BOM table) =
[ComboPI] (this is a combo that Filter Datas in the subForm, and are
equal
to
Base_ID)

I running this code in a Form named:BOM_PRINT and the SubForm where all
records are filtered is: QueryBOMsubform


could you please help...
=================================================
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B, Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM
tbl_BOM" & _
"WHERE Base_ID = ([ComboPI])"
DoCmd.SetWarnings True
=================================================
 
Hi Douglas, Thank you for answering me..

could you write me the correct code, since I correct the space but it show
the same Error.


thank you so much for your help.
LD



Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
You're missing a space between the closing parenthesis and the keyword
SELECT.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


ldiaz said:
Hi Douglas..

I have corrected the comma and the code now is so:
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B, Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

but at the time to run it show a message error saying "
SYNTAX ERROR in FROM CLAUSE..

is something else wrong?

--
Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
You've got a superfluous comma between UOM and FROM.

I'd also use

"WHERE Base_ID = " & Me.[ComboPI]

for the last line, assuming Base_ID is a numeric field. If it's text:

"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have this Code to INSERT INTO my Table named: BOM_EDIT_BuckUp with
fields:
(Base_ID_B, Code_Sub_B, Part_ID_B, Description_B, QtyPer1_B, UOM_B)"
and I want to get them from my Table named: tbl_BOM with these records:
Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM tbl_BOM just a
"_B" was added in the BackUp table,

but I want to Insert them, if Base_ID (this Data is from tbl-BOM table) =
[ComboPI] (this is a combo that Filter Datas in the subForm, and are equal
to
Base_ID)

I running this code in a Form named:BOM_PRINT and the SubForm where all
records are filtered is: QueryBOMsubform


could you please help...
=================================================
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B, Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM
tbl_BOM" & _
"WHERE Base_ID = ([ComboPI])"
DoCmd.SetWarnings True
=================================================
 
What's your current code?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


ldiaz said:
Hi Douglas, Thank you for answering me..

could you write me the correct code, since I correct the space but it show
the same Error.


thank you so much for your help.
LD



Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
You're missing a space between the closing parenthesis and the keyword
SELECT.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


ldiaz said:
Hi Douglas..

I have corrected the comma and the code now is so:
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B, Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

but at the time to run it show a message error saying "
SYNTAX ERROR in FROM CLAUSE..

is something else wrong?

--
Lorenzo Díaz
Cad Technician


:

You've got a superfluous comma between UOM and FROM.

I'd also use

"WHERE Base_ID = " & Me.[ComboPI]

for the last line, assuming Base_ID is a numeric field. If it's text:

"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have this Code to INSERT INTO my Table named: BOM_EDIT_BuckUp with
fields:
(Base_ID_B, Code_Sub_B, Part_ID_B, Description_B, QtyPer1_B, UOM_B)"
and I want to get them from my Table named: tbl_BOM with these records:
Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM
tbl_BOM
just a
"_B" was added in the BackUp table,

but I want to Insert them, if Base_ID (this Data is from tbl-BOM table) =
[ComboPI] (this is a combo that Filter Datas in the subForm, and
are
equal
to
Base_ID)

I running this code in a Form named:BOM_PRINT and the SubForm
where
all
records are filtered is: QueryBOMsubform


could you please help...
=================================================
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B, Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM
tbl_BOM" & _
"WHERE Base_ID = ([ComboPI])"
DoCmd.SetWarnings True
=================================================
 
here is:
=================================================
DoCmd.SetWarnings True
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B, Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)
DoCmd.SetWarnings False

=================================================


--
Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
What's your current code?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


ldiaz said:
Hi Douglas, Thank you for answering me..

could you write me the correct code, since I correct the space but it show
the same Error.


thank you so much for your help.
LD



Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
You're missing a space between the closing parenthesis and the keyword
SELECT.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi Douglas..

I have corrected the comma and the code now is so:
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM
tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

but at the time to run it show a message error saying "
SYNTAX ERROR in FROM CLAUSE..

is something else wrong?

--
Lorenzo Díaz
Cad Technician


:

You've got a superfluous comma between UOM and FROM.

I'd also use

"WHERE Base_ID = " & Me.[ComboPI]

for the last line, assuming Base_ID is a numeric field. If it's text:

"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have this Code to INSERT INTO my Table named: BOM_EDIT_BuckUp with
fields:
(Base_ID_B, Code_Sub_B, Part_ID_B, Description_B, QtyPer1_B, UOM_B)"
and I want to get them from my Table named: tbl_BOM with these
records:
Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM tbl_BOM
just a
"_B" was added in the BackUp table,

but I want to Insert them, if Base_ID (this Data is from tbl-BOM
table) =
[ComboPI] (this is a combo that Filter Datas in the subForm, and are
equal
to
Base_ID)

I running this code in a Form named:BOM_PRINT and the SubForm where
all
records are filtered is: QueryBOMsubform


could you please help...
=================================================
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B, Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM
tbl_BOM" & _
"WHERE Base_ID = ([ComboPI])"
DoCmd.SetWarnings True
=================================================
 
You still have no space between the ) and SELECT. Also, I just noticed that
you don't have one between tbl_BOM and WHERE.

DoCmd.SetWarnings True
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B, Part_ID_B,
Description_B, QtyPer1_B, UOM_B) " & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM tbl_BOM "
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)
DoCmd.SetWarnings False

Note that I've added spaces in , UOM_B) " & _ and tbl_BOM " & _

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


ldiaz said:
here is:
=================================================
DoCmd.SetWarnings True
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM
tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)
DoCmd.SetWarnings False

=================================================


--
Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
What's your current code?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


ldiaz said:
Hi Douglas, Thank you for answering me..

could you write me the correct code, since I correct the space but it
show
the same Error.


thank you so much for your help.
LD



Lorenzo Díaz
Cad Technician


:

You're missing a space between the closing parenthesis and the
keyword
SELECT.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi Douglas..

I have corrected the comma and the code now is so:
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM
tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

but at the time to run it show a message error saying "
SYNTAX ERROR in FROM CLAUSE..

is something else wrong?

--
Lorenzo Díaz
Cad Technician


:

You've got a superfluous comma between UOM and FROM.

I'd also use

"WHERE Base_ID = " & Me.[ComboPI]

for the last line, assuming Base_ID is a numeric field. If it's text:

"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have this Code to INSERT INTO my Table named: BOM_EDIT_BuckUp with
fields:
(Base_ID_B, Code_Sub_B, Part_ID_B, Description_B, QtyPer1_B, UOM_B)"
and I want to get them from my Table named: tbl_BOM with these
records:
Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM tbl_BOM
just a
"_B" was added in the BackUp table,

but I want to Insert them, if Base_ID (this Data is from
tbl-BOM
table) =
[ComboPI] (this is a combo that Filter Datas in the subForm,
and are
equal
to
Base_ID)

I running this code in a Form named:BOM_PRINT and the SubForm where
all
records are filtered is: QueryBOMsubform


could you please help...
=================================================
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B, Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM
tbl_BOM" & _
"WHERE Base_ID = ([ComboPI])"
DoCmd.SetWarnings True
=================================================
 
Thank you Douglas

I found the problem..


thank you so much again
--
Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
You still have no space between the ) and SELECT. Also, I just noticed that
you don't have one between tbl_BOM and WHERE.

DoCmd.SetWarnings True
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B, Part_ID_B,
Description_B, QtyPer1_B, UOM_B) " & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM tbl_BOM "
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)
DoCmd.SetWarnings False

Note that I've added spaces in , UOM_B) " & _ and tbl_BOM " & _

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


ldiaz said:
here is:
=================================================
DoCmd.SetWarnings True
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM
tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)
DoCmd.SetWarnings False

=================================================


--
Lorenzo Díaz
Cad Technician


Douglas J. Steele said:
What's your current code?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi Douglas, Thank you for answering me..

could you write me the correct code, since I correct the space but it
show
the same Error.


thank you so much for your help.
LD



Lorenzo Díaz
Cad Technician


:

You're missing a space between the closing parenthesis and the
keyword
SELECT.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi Douglas..

I have corrected the comma and the code now is so:
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B, Code_Sub_B,
Part_ID_B,
Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM FROM
tbl_BOM"
& _
"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

but at the time to run it show a message error saying "
SYNTAX ERROR in FROM CLAUSE..

is something else wrong?

--
Lorenzo Díaz
Cad Technician


:

You've got a superfluous comma between UOM and FROM.

I'd also use

"WHERE Base_ID = " & Me.[ComboPI]

for the last line, assuming Base_ID is a numeric field. If it's
text:

"WHERE Base_ID = " & Chr$(34) & Me.[ComboPI] & Chr$(34)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



I have this Code to INSERT INTO my Table named: BOM_EDIT_BuckUp
with
fields:
(Base_ID_B, Code_Sub_B, Part_ID_B, Description_B, QtyPer1_B,
UOM_B)"
and I want to get them from my Table named: tbl_BOM with these
records:
Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM, FROM
tbl_BOM
just a
"_B" was added in the BackUp table,

but I want to Insert them, if Base_ID (this Data is from
tbl-BOM
table) =
[ComboPI] (this is a combo that Filter Datas in the subForm,
and
are
equal
to
Base_ID)

I running this code in a Form named:BOM_PRINT and the SubForm
where
all
records are filtered is: QueryBOMsubform


could you please help...
=================================================
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO BOM_EDIT_BuckUp (Base_ID_B,
Code_Sub_B,
Part_ID_B, Description_B, QtyPer1_B, UOM_B)" & _
"SELECT Base_ID, Code_Sub, Part_ID, Description, QtyPer1, UOM,
FROM
tbl_BOM" & _
"WHERE Base_ID = ([ComboPI])"
DoCmd.SetWarnings True
=================================================
 

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

Back
Top