vba insert only updating two fields

Workaholic

Registered User.
Local time
Today, 10:16
Joined
Jun 20, 2004
Messages
17
I am using the following code to transfer data from text boxes to a table.

Private Sub cmdFeedSub_Click()

DoCmd.RunSQL
("INSERT INTO Interface_Feedback ([First Name],Surname,Comment)
VALUES (forms!frmfeedv2!txtFeedFname,forms!frmfeedv2!txtFeedSname,forms!frmfeedv2!txtFeedCom)")

End Sub


The problem is that only the first two fields are updated no matter how I try to write the statement.
 
Why not just bind the textboxes to the relevant table?
 
Im working it through a submit button rather than the auto update
 
Workaholic said:
Im working it through a submit button rather than the auto update

Yes, I've grasped that. Why?

Seems like a waste of time and resource to me.
 
Take it easy, I'm just not sure how to let the the user know that the data has been saved
 
Still trying to get to the root of your problem.

Your gain nothing and lose a performance by using your current method. The SQL you have is recreated every time that sub is run which means that your database is going to bloat exponentially as the query involved has to be converted from a string to a query each time and when a query is created spaces is reserved for it; similarly when a query is destroyed (every time the sub is run in this case) the space used by the query is not reclaimed. Expect your database to reach some ridiculous sizes if you don't compact it regularly.

Now, with your problem, you are (for some reason that you are keeping to yourself) trying to insert values into a table when there are other cleaner methods:

  1. Create a proper query definition that does the exact same thing and open that rather than recreate the temporary query each time;
  2. Bind the form where you are getting these values to a query based on the table you want to insert them to;
  3. Use ADO or DAO to enter the values into the table
 

Users who are viewing this thread

Back
Top Bottom