Connecting Tech Pros Worldwide Help | Site Map

insert into statement

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 04:22 PM
JMCN
Guest
 
Posts: n/a
Default insert into statement

i have a question regarding the insert into statement in access 97 database.
i wrote a small insert statement for my new table def ("tblImportET") but when
i run the code, no records are appended to "tblImportET".
i thought that the "*" would select all of the fields and then
import into the "tblImportET".

any advice would be appreciated - thanks jung
here is the code:
Set dbsEtrack = CurrentDb
'Set rstET = ("Exception Tracking")

'step one: delete the tdf("tblImportET")
dbsEtrack.TableDefs.Delete ("tblImportET")

'step two: Create a new TableDef object.
Set tdfNew = dbsEtrack.CreateTableDef("tblImportET")

With tdfNew

.Fields.Append .CreateField("ET LN Shortname", dbText)
.Fields.Append .CreateField("ET Amount", dbCurrency)
.Fields.Append .CreateField("ET EC Code", dbText)

'.Fields.Append.CreateField("ET Number", dbLong) = rstET![ET Number] + 1

' Append the new TableDef object to the Etrack
' database.
dbsEtrack.TableDefs.Append tdfNew

End With

dbsEtrack.TableDefs.Refresh

'step three: insert data from qryBMODReport into "tblImportET"
' nothing happens
insertsql = ("INSERT INTO [tblImportET] SELECT * FROM [qryBMODReport]")

  #2  
Old November 12th, 2005, 04:22 PM
Rick Brandt
Guest
 
Posts: n/a
Default Re: insert into statement

"JMCN" <picarama@yahoo.fr> wrote in message
news:2772ee20.0312041356.7226b2e3@posting.google.c om...[color=blue]
> i have a question regarding the insert into statement in access 97[/color]
database.[color=blue]
> i wrote a small insert statement for my new table def ("tblImportET") but[/color]
when[color=blue]
> i run the code, no records are appended to "tblImportET".
> i thought that the "*" would select all of the fields and then
> import into the "tblImportET".[/color]
[snip]

This line...
insertsql = ("INSERT INTO [tblImportET] SELECT * FROM [qryBMODReport]")

....is not how you execute a SQL statement in code. You need either
DoCmd.RunSQL or the Execute method of a Database object. I prefer the
latter.

dbsEtrack.Execute "INSERT INTO [tblImportET] SELECT * FROM
[qryBMODReport]", dbFailOnError


--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com


  #3  
Old November 12th, 2005, 04:22 PM
DFS
Guest
 
Posts: n/a
Default Re: insert into statement


JMCN,


Is there really a need to delete the tabledef? If so, you may need to do a

dbsEtrack.TableDefs.Refresh

after the table creation.

Alternatively, you don't have to create the tabledef that way at all. You
could just do

dbsEtrack.TableDefs.Delete ("tblImportET")
dbsEtrack.TableDefs.Refresh
dbsEtrack.Execute("SELECT * INTO tblImportET FROM [qryBMODReport];")
dbsEtrack.TableDefs.Refresh


"JMCN" <picarama@yahoo.fr> wrote in message
news:2772ee20.0312041356.7226b2e3@posting.google.c om...[color=blue]
> i have a question regarding the insert into statement in access 97[/color]
database.[color=blue]
> i wrote a small insert statement for my new table def ("tblImportET") but[/color]
when[color=blue]
> i run the code, no records are appended to "tblImportET".
> i thought that the "*" would select all of the fields and then
> import into the "tblImportET".
>
> any advice would be appreciated - thanks jung
> here is the code:
> Set dbsEtrack = CurrentDb
> 'Set rstET = ("Exception Tracking")
>
> 'step one: delete the tdf("tblImportET")
> dbsEtrack.TableDefs.Delete ("tblImportET")
>
> 'step two: Create a new TableDef object.
> Set tdfNew = dbsEtrack.CreateTableDef("tblImportET")
>
> With tdfNew
>
> .Fields.Append .CreateField("ET LN Shortname", dbText)
> .Fields.Append .CreateField("ET Amount", dbCurrency)
> .Fields.Append .CreateField("ET EC Code", dbText)
>
> '.Fields.Append.CreateField("ET Number", dbLong) = rstET![ET[/color]
Number] + 1[color=blue]
>
> ' Append the new TableDef object to the Etrack
> ' database.
> dbsEtrack.TableDefs.Append tdfNew
>
> End With
>
> dbsEtrack.TableDefs.Refresh
>
> 'step three: insert data from qryBMODReport into "tblImportET"
> ' nothing happens
> insertsql = ("INSERT INTO [tblImportET] SELECT * FROM[/color]
[qryBMODReport]")


  #4  
Old November 12th, 2005, 04:24 PM
JMCN
Guest
 
Posts: n/a
Default Re: insert into statement

"DFS" <nospamDS@nospam.com> wrote in message news:<vsvbst5dl4rk42@corp.supernews.com>...[color=blue]
> JMCN,
>
>
> Is there really a need to delete the tabledef? If so, you may need to do a
>
> dbsEtrack.TableDefs.Refresh
>
> after the table creation.
>
> Alternatively, you don't have to create the tabledef that way at all. You
> could just do
>
> dbsEtrack.TableDefs.Delete ("tblImportET")
> dbsEtrack.TableDefs.Refresh
> dbsEtrack.Execute("SELECT * INTO tblImportET FROM [qryBMODReport];")
> dbsEtrack.TableDefs.Refresh
>
>[/color]

i thought i had to delete it for updated information. but since the
refresh pretty much takes care of updating the newer loan information,
no i don't need to :) thanks again for the help!!!!
[color=blue]
> "JMCN" <picarama@yahoo.fr> wrote in message
> news:2772ee20.0312041356.7226b2e3@posting.google.c om...[color=green]
> > i have a question regarding the insert into statement in access 97[/color]
> database.[color=green]
> > i wrote a small insert statement for my new table def ("tblImportET") but[/color]
> when[color=green]
> > i run the code, no records are appended to "tblImportET".
> > i thought that the "*" would select all of the fields and then
> > import into the "tblImportET".
> >
> > any advice would be appreciated - thanks jung
> > here is the code:
> > Set dbsEtrack = CurrentDb
> > 'Set rstET = ("Exception Tracking")
> >
> > 'step one: delete the tdf("tblImportET")
> > dbsEtrack.TableDefs.Delete ("tblImportET")
> >
> > 'step two: Create a new TableDef object.
> > Set tdfNew = dbsEtrack.CreateTableDef("tblImportET")
> >
> > With tdfNew
> >
> > .Fields.Append .CreateField("ET LN Shortname", dbText)
> > .Fields.Append .CreateField("ET Amount", dbCurrency)
> > .Fields.Append .CreateField("ET EC Code", dbText)
> >
> > '.Fields.Append.CreateField("ET Number", dbLong) = rstET![ET[/color]
> Number] + 1[color=green]
> >
> > ' Append the new TableDef object to the Etrack
> > ' database.
> > dbsEtrack.TableDefs.Append tdfNew
> >
> > End With
> >
> > dbsEtrack.TableDefs.Refresh
> >
> > 'step three: insert data from qryBMODReport into "tblImportET"
> > ' nothing happens
> > insertsql = ("INSERT INTO [tblImportET] SELECT * FROM[/color]
> [qryBMODReport]")[/color]
  #5  
Old November 12th, 2005, 04:24 PM
JMCN
Guest
 
Posts: n/a
Default Re: insert into statement

"DFS" <nospamDS@nospam.com> wrote in message news:<vsvbst5dl4rk42@corp.supernews.com>...[color=blue]
> JMCN,
>
>
> Is there really a need to delete the tabledef? If so, you may need to do a
>
> dbsEtrack.TableDefs.Refresh
>
> after the table creation.
>
> Alternatively, you don't have to create the tabledef that way at all. You
> could just do
>
> dbsEtrack.TableDefs.Delete ("tblImportET")
> dbsEtrack.TableDefs.Refresh
> dbsEtrack.Execute("SELECT * INTO tblImportET FROM [qryBMODReport];")
> dbsEtrack.TableDefs.Refresh
>
>[/color]

i thought i had to delete it for updated information. but since the
refresh pretty much takes care of updating the newer loan information,
no i don't need to :) thanks again for the help!!!!
[color=blue]
> "JMCN" <picarama@yahoo.fr> wrote in message
> news:2772ee20.0312041356.7226b2e3@posting.google.c om...[color=green]
> > i have a question regarding the insert into statement in access 97[/color]
> database.[color=green]
> > i wrote a small insert statement for my new table def ("tblImportET") but[/color]
> when[color=green]
> > i run the code, no records are appended to "tblImportET".
> > i thought that the "*" would select all of the fields and then
> > import into the "tblImportET".
> >
> > any advice would be appreciated - thanks jung
> > here is the code:
> > Set dbsEtrack = CurrentDb
> > 'Set rstET = ("Exception Tracking")
> >
> > 'step one: delete the tdf("tblImportET")
> > dbsEtrack.TableDefs.Delete ("tblImportET")
> >
> > 'step two: Create a new TableDef object.
> > Set tdfNew = dbsEtrack.CreateTableDef("tblImportET")
> >
> > With tdfNew
> >
> > .Fields.Append .CreateField("ET LN Shortname", dbText)
> > .Fields.Append .CreateField("ET Amount", dbCurrency)
> > .Fields.Append .CreateField("ET EC Code", dbText)
> >
> > '.Fields.Append.CreateField("ET Number", dbLong) = rstET![ET[/color]
> Number] + 1[color=green]
> >
> > ' Append the new TableDef object to the Etrack
> > ' database.
> > dbsEtrack.TableDefs.Append tdfNew
> >
> > End With
> >
> > dbsEtrack.TableDefs.Refresh
> >
> > 'step three: insert data from qryBMODReport into "tblImportET"
> > ' nothing happens
> > insertsql = ("INSERT INTO [tblImportET] SELECT * FROM[/color]
> [qryBMODReport]")[/color]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.