append query

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.
 
J

Jeanette Cunningham

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
 
J

John Spencer

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

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

Similar Threads

Filter report 2
Listbox to database 3
Append Query Issue 0
Append query 3
Append query if criteria is not met 3
Access 2002 Append Query Problems 1
Append if Not Exist 4
Schedule Auto run Query on append table 0

Top