John Baker wrote:
Thanks:
I tried that, and set it up thus:
Private Sub NewMod__AfterUp date()
Dim strSQL As String
strSQL = "UPDATE tblPOModsmaker SET tblPOModsmaker. MOD number =
[Forms]![Makemodq1]![NewMod#];"
DoCmd.RunSQL strSQL
End Sub
I am getting an error which says "Syntax error in update statement". Can you see the
syntax problem, because I cant!
Thanks
Well....MOD is function that can get the modulus between 2 numbers. And I NEVER create
table/field names with spaces, dashes, underscores or whatever. Ex: You use Mod Number. I
use ModNumber. That way I avoid extra keystrokes (the need to surround by []'s) and
frankly...it looks better. But let's look at your statement.
Mod Number should be tblPOModsmaker.[MOD number].
If this was a query, it'd run fine. However, in VBA you need to parse data out so Access knows
what to do. Ex: Access flunks on [Forms]![Makemodq1]![NewMod#] when it is contained in the
string. It has NO idea what the heck that is. But...if you change it to
strSQL = "UPDATE tblPOModsmaker " & _
"SET tblPOModsmaker.[MOD number] = " & [Forms]![Makemodq1]![NewMod#]
then that should work....except if
newmod# is a string or date.
Ex "Where DateField = #" & Date & "#"
Ex: "Where MyName = '" & varName & "'"
Did you see where name is quote, single quote, quote. If you know that a text filed could
contain double or single quotes, you need to futz with that. There is discussion on quotes in
the Access Developers Guide. You can also check google for that.
In my example, I figure NewMod# is a number. No quotes or #'s are needed