Strange docmd.runsql behavior

  • Thread starter Thread starter arumage
  • Start date Start date
A

arumage

If I have warnings turned on like in the code below, the insert runs fine,
although it interupts the user to push OK, but if I set warnings to false,
it's almost as if it just ignores the insert all together. It's doesn't make
alot of sense to me why it would make any difference. Does anyone know why
it would be doing this or a way around it? I really don't want to interrupt
the process to have the user click OK a bunch of times.

DoCmd.SetWarnings True

DoCmd.RunSQL ("INSERT INTO [Leaf Orders]([LeafColor], [LeafColorActual],
[shaft], [Width], [Draw], [Pass], [Location], [B-W], [DesignNum], [Sheet],
[MarketNum], [Program], [pull1], [pull2], [length1], [length2]) VALUES('" &
ColorMeBad & "', '" & ColorMeBad & "', '" & shaft & "', " & Width & ", " &
Draw4 & ", " & Pass1 & ", '" & Location & "', '" & BorW5 & "', '" & CardNo &
"', '" & CardNo2 & "', '" & CardNo3 & "', " & Program & ", " & pull1 & ", " &
pull2 & ", " & length1 & ", " & length2 & ")")

DoCmd.SetWarnings False
 
Instead of Docmd.RunSQL, use
Currentdb.Execute <sql statment>, dbFailOnError

It bypasses the Access User Interface and goes directly to Jet, so it will
not trigger the warnings. It is also faster.

What do you mean by "it's almost as if it just ignores the insert all
together"?
Are you saying it doesn't do the update? How do you know? have you checked
the data?
 
Back
Top