Afterupdate - Update a record's field data to null?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to have an event that once you click this button or that
button, it updates the current record's data for a certain field. Like for
the current record, it has a YES value for a checkbox named PDFPrintFile, so
when you do another action, it will then update that record's data for that
field to say NO.

I know you can do this with an update query, but then you have that stupid
message come up!

Curtis
 
In a form, you don't update a field at a time. The entire record is updated
when you take any action that causes an update. That includes moving to a
different record, starting a new record, or closing the form. You can also
do it programatically.

If you are wanting to update using a query without the warning messages,
there are two ways to do it.

Docmd.Setwarnings False
Docmd.RunSQL strSQL
Docmd.Setwarnings True

The other, which is faster and does not trigger warning messages

CurrentDb.Execute(strSQL), dbFailOnError
 
Where would I place that in this event?

============================
Private Sub Report_Close()

On Error GoTo Err_Report_Close

Dim stDocName As String

stDocName = "UpdatePDFPrinter"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Report_Close:
Exit Sub

Err_Report_Close:
MsgBox Err.Description
Resume Exit_Report_Close

End Sub
============================
 
Nevermind, it doesn't show up a message when I did an update query. Is it
suppose to pop up a message when you do an update query? I thought so but
noticed none of them are doing it....

Thanks
Curtis
 
Well, I'm a little confused. The OpenQuery method is for select and crosstab
queries. I am putting in the code below in the hope that UpdatePDFPrinter is
really an update query.
 
Yes, it is an update query, I'm a cheater, I create command buttons, take
that code, etc. I don't know VB that well to just start typing a whole bunch
& didn't catch that.

Curtis
 
The CurrentDb.Execute does not go through the Access User Interface, so it
will not only not show warning messages, it will not show an error. That is
why you need the dbFailOnError. It will cause an error to raise if one
occurs.
 
Back
Top