1

I am trying to insert data into a table in my MS Access database.

When doing so MS Access informs me that I am about to append 1 row.

When I return to the table to check the data I still have a blank table.

If I click on the Filters on the table I can see my data as options but they will not show up in the actual table.

INSERT INTO PATIENTS (PatID, FirstName, LastName, Age, Phone, InsuranceCompany)
VALUES (00000090, 'Luke', 'Howell', 42, 7709999785, 'Blue Cross Blue Shield' );
3
  • are you sure you are looking against the same table? Commented Jun 17, 2015 at 20:24
  • Yes i am looking at the correct table @Rahul Commented Jun 17, 2015 at 20:28
  • It is a table in Ms Access @HansUp Commented Jun 17, 2015 at 20:34

2 Answers 2

1

When the INSERT runs without error, but also without actually adding a row to the table, that could be the result of a key violation. However Access won't notify you if you're using DoCmd.RunSQL to execute the statement. In other situations, a notice could be suppressed if you have turned SetWarnings off.

Run your INSERT with the DAO.Database.Execute method and its dbFailOnError option. Also make sure SetWarnings is on ...

Dim strInsert As String
strInsert = "INSERT INTO PATIENTS (PatID, FirstName, LastName, Age, Phone, InsuranceCompany) " & _
    "VALUES (00000090, 'Luke', 'Howell', 42, 7709999785, 'Blue Cross Blue Shield' );"
Debug.Print strInsert '<- view this in Immediate window; Ctrl+g will take you there
DoCmd.SetWarnings True
CurrentDb.Execute strInsert, dbFailOnError
Sign up to request clarification or add additional context in comments.

1 Comment

I am kind of not understanding how to input this code into MS Access as it gives me a error of "Invalid SQL Statement Expected"
0

So I Figured It Out.

I Was Not In The "Datasheet View"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.