Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Trying to add and update records on one button to my subform

$
0
0
Im trying to update my edit fields if I click the edit button it changes the Add caption to update so where ill have two adds where ill add my new fields and where ill update the existing fields everything is working im just trying to solve solution.
I get this error: Run-time error '3134'.
Syntax error in UPDATE statement.
Thanks for helping me people appreciated aloth. ;)

Private Sub cmdAdd_Click()

Dim strSQL As String

If Me.txtTranID.Tag & "" = "" Then

strSQL = "INSERT INTO PlantTransactionQuery (TransactionID, [PlantTransaction_Plant Number], Categories, Description, Location, [TransactionDate], Opening_Hours, Closing_Hours, [Hours Worked], Fuel, [Fuel Cons Fuel/Hours], [Hour Meter Replaced], Comments) "
strSQL = strSQL & "VALUES (" & txtTranID & ", '" & txtPlantNo & "', '" & txtCategories & "', '" & txtDescription & "', '" & txtLocation & "', #" & txtTransDate & "#, " & txtOpenHrs & ", " & CloseHrs & ", " & txtHrsWorked & ", '" & txtFuel & "', " & txtFuelConsFuelHr & ", " & txtHrMtrRep & ", '" & txtComments & "');"
CurrentDb.Execute strSQL
Else
strSQL = "UPDATE PlantTransactionQuery " & _
"SET TransactionID=" & Me.txtTranID & _
",PlantTransaction_Plant Number='" & Me.txtPlantNo & "'" & _
",Categories='" & Me.txtCategories & "'" & _
",Description='" & Me.txtDescription & "'" & _
",Location='" & Me.txtLocation & "'" & _
",TransactionDate='" & Me.txtTransDate & "'" & _
",Opening_Hours='" & Me.txtOpenHrs & "'" & _
",Closing_Hours='" & Me.txtDescription & "'" & _
",Hours Worked='" & Me.txtDescription & "'" & _
",Fuel='" & Me.txtFuel & "'" & _
",Fuel Cons Fuel/Hours='" & Me.txtFuelConsFuelHr & "'" & _
",Hour Meter Replaced='" & Me.txtHrMtrRep & "'" & _
",Comments='" & Me.txtComments & "'" & _
" WHERE TransactionID=" & Me.txtTranID.Tag
CurrentDb.Execute strSQL
End If
End Sub

Viewing all articles
Browse latest Browse all 13329

Trending Articles