SQL Not working right (1 Viewer)

NJudson

Who farted?
Local time
Yesterday, 23:46
Joined
Feb 14, 2002
Messages
297
I'm running a simple bit of code to delete the contents of a table and then populate the table based on a query. The problem is when I run the query I get 776 records. When I run the code to populate the table with the query then I only get 771 records. Can anyone help me to understand why I'm not getting all 776 records and what I might need to do to fix this? Thanks.

Function LoadAndrewTemplateContents()
Dim dbs As DAO.Database
Set dbs = CurrentDb
Dim SQL As String
Call ClearAndrewTemplateContents
SQL = "INSERT INTO AndrewTemplate SELECT * FROM qryCellDataFilterXorOmni": dbs.Execute (SQL)
End Function

Function ClearAndrewTemplateContents()
Dim dbs As DAO.Database
Set dbs = CurrentDb
dbs.Execute ("DELETE * FROM AndrewTemplate")
End Function
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 20:46
Joined
Aug 30, 2003
Messages
36,139
First thing I would check is that the table has a key field(s) that some incoming records would violate. In other words, if there's an ID field that doesn't allow duplicates, does the query have more than one record with the same ID?
 

NJudson

Who farted?
Local time
Yesterday, 23:46
Joined
Feb 14, 2002
Messages
297
Thanks for the reply. The more I'm looking into this I think the problems I'm having are turning out to be datafill inconsistencies with the table I'm querying. The query and sql that I've written is correct but I need to go through the table and make sure that the data is correct so the query doesn't result in bogus information. What a fun job this is going to be! :rolleyes:
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:46
Joined
Feb 19, 2002
Messages
43,626
You didn't post the query that supplies the records for the insert.
 

Users who are viewing this thread

Top Bottom