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.OL
EDB.12.0;D
ata Source=C:\Documents and Settings\andy\Desktop\Prob
lem\Produc
tion\TBL_I
NFO.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
Andy
Start Free Trial