mole999
New member
- Local time
- Today, 12:49
- Joined
- Dec 28, 2008
- Messages
- 4
I stole this from here, thought I could fathom how to adapt it for my use haha
I get an error 3144 syntax error in this string DoCmd.RunSQL "UPDATE " & strTABLE & " SET " & strTABLE & "." & _
strFIELD & " = '" & strNEW & "' WHERE " & strTABLE & "." & _
strFIELD & " = '" & strOLD & "'"
I was trying to apply it to a file, with some unassuming names, the test table is called table3, the record entry is called 'entry', the newvalue and oldvalue reside in table 2.
newvalue and old value are text fields, entry is a memo field, there could be five or six values in each record/entry field and i want to replace them all.
2nd option would be on the neatest way to write an update query, and i will use 50 of those linked together to do what I need,
why am I doing this, well, some of my inputters will not turn caps lock off so the spell check is buggered, I can convert the case across so i get it in sentence case, but some words must be in upper case and auto correct won't fix as its not being typed, hence this route. It doesn't need to be pretty, just save me hours of work before turning it into a weekly report of some 40 pages, oh yes also at remote sites so can't control the input
Access 2003
Code:
Sub Entry_GotFocus()
'Private Sub ChangeUoM_Click()
Dim db As Database
Dim rs As Recordset
Dim strTABLE As String
Dim strFIELD As String
Dim strOLD As String
Dim strNEW As String
Set db = CurrentDb
Set rs = db.OpenRecordset("Table2", dbOpenDynaset)
DoCmd.SetWarnings False
With rs
.MoveFirst
While Not .EOF
strTABLE = Table3 '!ERPTable
strFIELD = Entry '!ERPField
strOLD = !OldValue
strNEW = !NewValue
DoCmd.RunSQL "UPDATE " & strTABLE & " SET " & strTABLE & "." & _
strFIELD & " = '" & strNEW & "' WHERE " & strTABLE & "." & _
strFIELD & " = '" & strOLD & "'"
.MoveNext
Wend
End With
rs.Close
DoCmd.SetWarnings True
Set rs = Nothing
Set db = Nothing
'End Sub
End Sub
strFIELD & " = '" & strNEW & "' WHERE " & strTABLE & "." & _
strFIELD & " = '" & strOLD & "'"
I was trying to apply it to a file, with some unassuming names, the test table is called table3, the record entry is called 'entry', the newvalue and oldvalue reside in table 2.
newvalue and old value are text fields, entry is a memo field, there could be five or six values in each record/entry field and i want to replace them all.
2nd option would be on the neatest way to write an update query, and i will use 50 of those linked together to do what I need,
why am I doing this, well, some of my inputters will not turn caps lock off so the spell check is buggered, I can convert the case across so i get it in sentence case, but some words must be in upper case and auto correct won't fix as its not being typed, hence this route. It doesn't need to be pretty, just save me hours of work before turning it into a weekly report of some 40 pages, oh yes also at remote sites so can't control the input
Access 2003
Last edited: