jeffro
Sep 15th, 2000, 08:47 AM
Hey
I'm trying to update a database table from vb. When I make a change to 2 out of the 3 fields and click on cmdupdate I get an syntax error (missing operator)in query expression '*Machineno'. I'm not sure what it is telling me. Have any ideas?
Here is the code from the cmdupdate:
Private Sub cmdUpdate_Click()
Dim stroldMachineno As String
Dim stroldMachineDesc As String
Dim stroldDivision As String
Dim strMessage As String
On Error GoTo ErrorUpdate
Set rsMachineInfo = New ADODB.Recordset
rsMachineInfo.Open "Select * Machineno, MachineDesc, Division From MachineInfo", cnn, adOpenDynamic, adLockOptimistic, adCmdText
stroldMachineno = rsMachineInfo!Machineno
stroldMachineDesc = rsMachineInfo!MachineDesc
stroldDivision = rsMachineInfo!Division
rsMachineInfo!Machineno = txtMachineno
rsMachineInfo!MachineDesc = txtMachineDesc
rsMachineInfo!Division = txtDivision
strMessage = "Edit in progress:" & vbCr & _
" Original data = " & stroldMachineno & " " & _
stroldMachineDesc & "" & stroldDivision & vbCr & " Data in buffer = " & _
rsMachineInfo!Machineno & " " & rsMachineInfo!MachineDesc & "" & rsMachineInfo!Division & vbCr & vbCr & _
"Use Update to replace the original data with " & _
"the buffered data in the Recordset?"
If MsgBox(strMessage, vbYesNo) = vbYes Then
rsMachineInfo.Update
Else
rsMachineInfo.CancelUpdate
End If
MsgBox "Data in recordset = " & rsMachineInfo!Machineno & " " & _
rsMachineInfo!MachineDesc & "" & rsMachineInfo!Division
' Restore original data because this is a demonstration.
If Not (stroldMachineno = rsMachineInfo!Machineno And _
stroldMachineDesc = rsMachineInfo!MachineDesc And stroldDivision = rsMachineInfo!Division) Then
rsMachineInfo!Machineno = stroldMachineno
rsMachineInfo!MachineDesc = stroldMachineDesc
rsMachineInfo!Division = stroldDivision
rsMachineInfo.Update
End If
rsMachineInfo.Close
ExitUpdate:
Exit Sub
ErrorUpdate:
MsgBox Err.Number & vbCrLf & Err.Description, , "ERROR"
Resume ExitUpdate
End Sub
I'm trying to update a database table from vb. When I make a change to 2 out of the 3 fields and click on cmdupdate I get an syntax error (missing operator)in query expression '*Machineno'. I'm not sure what it is telling me. Have any ideas?
Here is the code from the cmdupdate:
Private Sub cmdUpdate_Click()
Dim stroldMachineno As String
Dim stroldMachineDesc As String
Dim stroldDivision As String
Dim strMessage As String
On Error GoTo ErrorUpdate
Set rsMachineInfo = New ADODB.Recordset
rsMachineInfo.Open "Select * Machineno, MachineDesc, Division From MachineInfo", cnn, adOpenDynamic, adLockOptimistic, adCmdText
stroldMachineno = rsMachineInfo!Machineno
stroldMachineDesc = rsMachineInfo!MachineDesc
stroldDivision = rsMachineInfo!Division
rsMachineInfo!Machineno = txtMachineno
rsMachineInfo!MachineDesc = txtMachineDesc
rsMachineInfo!Division = txtDivision
strMessage = "Edit in progress:" & vbCr & _
" Original data = " & stroldMachineno & " " & _
stroldMachineDesc & "" & stroldDivision & vbCr & " Data in buffer = " & _
rsMachineInfo!Machineno & " " & rsMachineInfo!MachineDesc & "" & rsMachineInfo!Division & vbCr & vbCr & _
"Use Update to replace the original data with " & _
"the buffered data in the Recordset?"
If MsgBox(strMessage, vbYesNo) = vbYes Then
rsMachineInfo.Update
Else
rsMachineInfo.CancelUpdate
End If
MsgBox "Data in recordset = " & rsMachineInfo!Machineno & " " & _
rsMachineInfo!MachineDesc & "" & rsMachineInfo!Division
' Restore original data because this is a demonstration.
If Not (stroldMachineno = rsMachineInfo!Machineno And _
stroldMachineDesc = rsMachineInfo!MachineDesc And stroldDivision = rsMachineInfo!Division) Then
rsMachineInfo!Machineno = stroldMachineno
rsMachineInfo!MachineDesc = stroldMachineDesc
rsMachineInfo!Division = stroldDivision
rsMachineInfo.Update
End If
rsMachineInfo.Close
ExitUpdate:
Exit Sub
ErrorUpdate:
MsgBox Err.Number & vbCrLf & Err.Description, , "ERROR"
Resume ExitUpdate
End Sub