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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|