Advertisement

03.10.2008 at 03:59AM PDT, ID: 23227965
[x]
Attachment Details

mysql INSERT error Unknown field?

Asked by samandrew in Databases Miscellaneous, Microsoft Access Database, VB Database Programming

Tags: VB6

Hi
I have the following connection to a database called TBL_INFO

Public myConnection As ADODB.Connection
 Dim rs As New ADODB.Recordset
Public Function Get_My_Connection() As ADODB.Connection
     If myConnection Is Nothing Then
           Set myConnection = New ADODB.Connection
           myConnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\andy\Desktop\Problem\Production\TBL_INFO.accdb;Persist Security Info=False;"
     End If
     Set Get_My_Connection = myConnection
End Function
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
I also have a cmdButton called cmdSaveData with the following code

Private Sub cmdSaveData_Click(Index As Integer)
Dim response As Integer
Dim mysql As String
   
mysql = "SELECT Count(*) AS RecExists FROM AldiRounds WHERE Date = #" & txtDate.Text & "#"
 
 rs.Open mysql, Get_My_Connection
 
If rs!RecExists > 0 Then
      mysql = "UPDATE AldiRounds Set Atherstone = " & Val(txtATHact.Text) & ",Athord = " & Val(txtATHord.Text) & ", Chelmsford = " & Val(txtCHEact.Text) & ",Cheord = " & Val(txtCHEord.Text) & ", Darlington = " & Val(txtDARact.Text) & ",Darord = " & Val(txtDARord.Text) & ", Middleton = " & Val(txtMIDact.Text) & ", Midord = " & Val(txtMIDord.Text) & ", Neston = " & Val(txtNESact.Text) & ",Nesord = " & Val(txtNESord.Text) & ", Swindon = " & Val(txtSWIact.Text) & ",Swiord = " & Val(txtSWIord.Text) & ", AldiRoundsDailyTotal = " & Val(txtACTtotal.Text) & " Where [Date] = #" & txtDate.Text & "#"
     
Get_My_Connection.Execute mysql
      MsgBox "ALDI ORDERS SUCESSFULLY UPDATED", vbOKOnly
   
Else
    mysql = "INSERT INTO AldiRounds (Atherstone, Athord, Chelmsford, Cheord, Darlington, Darord, Middleton, Midord, Neston, Nesord, Swindon, Swiord, AldiRoundsDailyTotal, [Date]) Values (" & Val(txtATHact.Text) & "," & Val(txtATHord.Text) & "," & Val(txtCHEact.Text) & "," & Val(txtCHEord.Text) & "," & Val(txtDARact.Text) & "," & Val(txtDARord.Text) & "," & Val(txtMIDact.Text) & "," & Val(txtMIDord.Text) & "," & Val(txtNESact.Text) & "," & Val(txtNESord.Text) & "," & Val(txtSWIact.Text) & "," & Val(txtSWIord.Text) & "," & Val(txtACTtotal.Text) & ", #" & txtDate.Text & "#)"
    Get_My_Connection.Execute mysql
    MsgBox "ALDI ORDERS SUCESSFULLY CREATED", vbOKOnly
End If
rs.Close
End Sub
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

My problem is when I try to Save to my database I get an error code saying

The INSERT INTO STATEMENT contains the following unknown field `Athord` Make sure you have typed the name correctly, and try again.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
My Database (Microsoft Office Access 2007)has the following fields
Date
Atherstone
Athord
Chelmsford
Cheord
Darlington
Darord
Middleton
Midord
Neston
Nesord
Swindon
Swiord
AldiRoundsDailyTotal

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

And I cannot see where I am going wrong can someone please help.

Many Thanks
AndyStart Free Trial
[+][-]03.10.2008 at 04:10AM PDT, ID: 21085320

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]03.10.2008 at 04:13AM PDT, ID: 21085330

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Databases Miscellaneous, Microsoft Access Database, VB Database Programming
Tags: VB6
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03.10.2008 at 05:20AM PDT, ID: 21085657

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.10.2008 at 07:39AM PDT, ID: 21086727

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.10.2008 at 11:11AM PDT, ID: 21088718

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.11.2008 at 04:28AM PDT, ID: 21094630

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628