lorena Posted June 22, 2005 Posted June 22, 2005 I keep getting this error: "Number of query values and destination fields are not the same" I have exactly the same number of fields in my query that are in the database and they are in the same order. I even went so far as to take the parameter values out and substitute hard-coded values and it still throws up. I am not sure what I am doing wrong. Do I have to have a Primary Key for this to work? All this app does is record form data to be exported to a spreadsheet. Here is my code: Sub AddRecord() Dim strConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=\\intranet\databases\results.mdb" Dim strSQL, strPlant, strTire, strFilter, strWiper As String Dim objCommand As OleDb.OleDbCommand Dim objConn As New OleDb.OleDbConnection(strConnString) 'Create SQL String strSQL = "Insert into PML(Customer, PhoneNo, PlantNo, CarYear, CarMake, CarModel, " strSQL = strSQL + " DropOff, NeededBy, AirFilter, WiperBlades, Rotation) VALUES " strSQL = strSQL + " ('Ethel Mertz', '555-5555', '1', 'Toyota', 'Corolla', '2001', " strSQL = strSQL + " '730'. '430', 'Y', 'N', 'Y')" objCommand = New OleDb.OleDbCommand(strSQL, objConn) objConn.Open() objCommand.ExecuteNonQuery() objConn.Close() End Sub Any help would be appreciated. Thanks Quote
Administrators PlausiblyDamp Posted June 22, 2005 Administrators Posted June 22, 2005 Not sure if it's a typo in entering it here but you have a . between the '730' and '430' rather than a comma. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Aspnot Posted June 23, 2005 Posted June 23, 2005 You can also try putting a break in after you build strSQL and determine exactly what strSQL states. Then copy and paste that into a query in MS Access and then try to execute it. MS Access usually gives better info about the error when you do it that way. Quote Aspnot
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.