append query

  • Thread starter Thread starter Ernst Guckel
  • Start date Start date
E

Ernst Guckel

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.
 
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
 
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
..
 
Back
Top