Originally Posted by
mikesal57
It worked somehow....but not from the macro I created...
Pictures of what happen when I rAn Macro....and.......pictures of when I RAN it from ALT-11 screen...
Sorry, I'm not familiar with running vba from a macro. I think most of us try to stay away from macros in general. Is this something that will need to be repeated often? If so just call the sub from a command button on a form. Otherwise I'd just run it from the vba editor window.
IF the format of your column names is nPOS01 through nPOS37 I propose a slight code modification:
Code:
Public Sub SetZerosToNull()
On Error GoTo ErrHandler
Dim db As DAO.Database
Dim update_qry As String
Dim i As Integer
Set db = CurrentDb
For i = 1 To 37
update_qry = "UPDATE [ALL_HX44] SET nPOS" & Format(i, "##") & " = null WHERE nPOS" & Format(i, "##") & " = 0;"
'Debug.Print update_qry
db.Execute update_qry, dbFailOnError
Next
ExitHandler:
Set db = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description, , "Error #" & Err.Number
Resume ExitHandler
End Sub