A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

append query



 
 
Thread Tools Display Modes
  #1  
Old March 21st, 2008, 12:31 AM posted to microsoft.public.access.queries
Ernst Guckel
external usenet poster
 
Posts: 50
Default append query

Hello,

I am trying to add 1 record to a table using an append query... but it
does not stop at one record... here is the code...

strSQL = "INSERT INTO tblSOS ( SOSDate ) SELECT " & Format(Me.txtMealDate,
STRING_DATE) & " FROM tblSOS;"

all i am looking to do is add txtmealdate to SOSDate in tblSOS

I am also not sure how to check if it has already been added. I don't want
to add it twice.

Thanks,
Ernst.

  #2  
Old March 21st, 2008, 04:18 AM posted to microsoft.public.access.queries
Jeanette Cunningham
external usenet poster
 
Posts: 2,190
Default append query

Ernst,
If you have only one value to append you can do the append query like this:


strSQL = "INSERT INTO tblSOS ( SOSDate ) " _
& "VALUES ( #2/21/2008# )"


Jeanette Cunningham

"Ernst Guckel" wrote in message
...
Hello,

I am trying to add 1 record to a table using an append query... but it
does not stop at one record... here is the code...

strSQL = "INSERT INTO tblSOS ( SOSDate ) SELECT " & Format(Me.txtMealDate,
STRING_DATE) & " FROM tblSOS;"

all i am looking to do is add txtmealdate to SOSDate in tblSOS

I am also not sure how to check if it has already been added. I don't
want
to add it twice.

Thanks,
Ernst.




  #3  
Old March 21st, 2008, 11:27 AM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default append query

And you could use DCount before attempting to run the append query to
determine if the data already existed in the table.

If DCount("*","tblSOS","SOSDATE=" & _
Format(Me.txtMealDate,STRING_DATE) = 0 Then

strSQL = "INSERT INTO tblSOS ( SOSDate ) " _
& "VALUES ( " & Format(Me.txtMealDate,STRING_DATE) & " ) "

CurrentDb().Execute strSQL, dbFailOnError

End If
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Jeanette Cunningham" wrote in message
...
Ernst,
If you have only one value to append you can do the append query like
this:


strSQL = "INSERT INTO tblSOS ( SOSDate ) " _
& "VALUES ( #2/21/2008# )"


Jeanette Cunningham

"Ernst Guckel" wrote in message
...
Hello,

I am trying to add 1 record to a table using an append query... but it
does not stop at one record... here is the code...

strSQL = "INSERT INTO tblSOS ( SOSDate ) SELECT " &
Format(Me.txtMealDate,
STRING_DATE) & " FROM tblSOS;"

all i am looking to do is add txtmealdate to SOSDate in tblSOS

I am also not sure how to check if it has already been added. I don't
want
to add it twice.

Thanks,
Ernst.






 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.