Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO .. from a FORM to table 1

Status
Not open for further replies.

5694

MIS
May 19, 2003
6
US
I have a FORM where the user creates or update project profile. Most of the data being entered will be inserted into the "Project" table, and three of the fields in that FORM belong in the "Status" table.
When clicking "Save Button", I need these three fields (projectid, statusUpdate, LastUpdateDate) to be inserted in “Status” table. It is one to many relationship (one Project many Status).

Here is my code
Dim db As Database
Dim strSQL As String
Set db = CurrentDb()

strSQL = "INSERT INTO STATUS (projectid,statusUpdate,LastUpdateDate) VALUES
('" & ([Forms]![Project]![Text21]) & "'),'" & ([Forms]![Project]![status_update]) & "'),'" & ([Forms]![Project]![LastUpdateDate]) & "') "

DoCmd.RunSQL (strSQL)


When I run this code, I got this error mas.
Number of query values and destination fields are not the same.

I want ([Forms]![Project]![Text21]) to be inserted for projectid and same for the other two.
I believe access is treating ([Forms]![Project]![Text21]) as 3 different values instead of one. Is there a way to get around this?

Thanks
5694
 
I think you may have one or more extra parentheses. Try this:

Code:
strSQL = "INSERT INTO STATUS (projectid,statusUpdate,LastUpdateDate) VALUES " _
& "('" & Me![Text21] & "','" & Me![status_update] & "','" & Me![LastUpdateDate] & "')"

HTH...

Ken S.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top