Link to home
Start Free TrialLog in
Avatar of Jass Saini
Jass Saini

asked on

How to put zeros as place holders

I have a code that runs and puts the remarks into fields that have a value...I want to run that code and also place a zero for BC1 that does not have a value.

Private Sub Remarks1_AfterUpdate()
 Dim rst As DAO.Recordset
   Dim strRemarks As String
   
    strRemarks = Me.Remarks1
    If strRemarks = "" Then Exit Sub
   
   Set rst = CurrentDb.OpenRecordset("Final_Table")
   'strRemarks = Me.Remarks1

   Do
      rst.Edit
        If Nz(rst![BC1Chng1]) <> "" Then
         rst![Remarks1] = strRemarks
      Else
         rst![Remarks1] = Null
      End If
      rst.Update
      rst.MoveNext

   Loop Until rst.EOF
   

End Sub

Open in new window

Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

This should work:

  rst.Edit
        If Nz(rst![BC1Chng1]) <> "" Then
         rst![Remarks1] = strRemarks
      Else
         rst![Remarks1] = "0"
      End If
      rst.Update
      rst.MoveNext
Avatar of Jass Saini
Jass Saini

ASKER

Hello Scott,

Sorry..I need to set BC1 to 0 is there is no value in there..the value can be positive or negative
ASKER CERTIFIED SOLUTION
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I tried this code and BC1Change has a "0" in all the records
Try to upload a sample database demonstrating the issue.
Perhaps:

rst.Edit
        If Nz(rst![BC1Chng1]) <> "" Then
         rst![Remarks1] = strRemarks
      Else
        rst![BC1] = "0"
      End If
      rst.Update
      rst.MoveNext