Use a checkbox to add/remove a note

  • Thread starter Darrell Childress
  • Start date
D

Darrell Childress

I have a form with a checkbox (NoEngrReqd) and the following code:
This takes anything in the "Notes" field and adds a line return and the
text ***NO ENGINEERING REQ'D***. It works fine, but I'd like to know if
there is a way that the user can come back in to this order and UNCHECK
the "NoEngrReqd" box and have it automatically remove the phrase ***NO
ENGINEERING REQ'D***
Right now, they have to manually delete the text.
I was thinking of another solution. Create an unbound field (make
invisible) and make that field contain the above text if checked, NULL
if unchecked, and then add the contents of that field to the "Notes"
field. But then I would have to have another field called "FinalNotes"
to contain "Notes" + the unbound field. Any other suggestions?

Private Sub NoEngrReqd_BeforeUpdate(Cancel As Integer)
If Me.NoEngrReqd = True Then
Me.Notes = Notes & Chr(13) & Chr(10) & " ***NO ENGINEERING
REQ'D***"
Else
Me.Notes = Notes
End If
End Sub
 
F

fredg

I have a form with a checkbox (NoEngrReqd) and the following code:
This takes anything in the "Notes" field and adds a line return and the
text ***NO ENGINEERING REQ'D***. It works fine, but I'd like to know if
there is a way that the user can come back in to this order and UNCHECK
the "NoEngrReqd" box and have it automatically remove the phrase ***NO
ENGINEERING REQ'D***
Right now, they have to manually delete the text.
I was thinking of another solution. Create an unbound field (make
invisible) and make that field contain the above text if checked, NULL
if unchecked, and then add the contents of that field to the "Notes"
field. But then I would have to have another field called "FinalNotes"
to contain "Notes" + the unbound field. Any other suggestions?

Private Sub NoEngrReqd_BeforeUpdate(Cancel As Integer)
If Me.NoEngrReqd = True Then
Me.Notes = Notes & Chr(13) & Chr(10) & " ***NO ENGINEERING
REQ'D***"
Else
Me.Notes = Notes
End If
End Sub


Does your version of Access include the Replace() function (Access
2000 or newer)?
I assume in addition to removing the "...No Engineering ..." text you
would also like to remove the chr(13) & chr(10).
Code the Check box AfterUpdate (not BeforeUpdate) event:

If Me.NoEngrReqd = True Then
Me.Notes = Me.Notes & Chr(13) & Chr(10) & " ***NO ENGINEERING
REQ'D***"
Else
Me.Notes = Replace(Me.Notes,Chr(13) & Chr(10) & " ***NO
ENGINEERING REQ'D***","")
End If
 
D

Darrell Childress

That works great...thanks for the help!!
Does your version of Access include the Replace() function (Access
2000 or newer)?
I assume in addition to removing the "...No Engineering ..." text you
would also like to remove the chr(13) & chr(10).
Code the Check box AfterUpdate (not BeforeUpdate) event:

If Me.NoEngrReqd = True Then
Me.Notes = Me.Notes & Chr(13) & Chr(10) & " ***NO ENGINEERING
REQ'D***"
Else
Me.Notes = Replace(Me.Notes,Chr(13) & Chr(10) & " ***NO
ENGINEERING REQ'D***","")
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top