Using VBA to delete data from one field in a table

Indigo

Registered User.
Local time
Today, 12:29
Joined
Nov 12, 2008
Messages
241
I am using a continuous form bound to a table to record unsafe driving
activites to a separate table. I have that module working. However,
as the form is bound, it is more or less a place marker and I need to
delete the data from one field in the table. I have tried to work out the module, but am stumped. Here it is:

Code:
Dim dbObject As DAO.Database
Dim strQuery As String
Dim HoldUnsafeTally As Variant
  HoldUnsafeTally = Forms!frmDriveAudit!subfrmUnsafe.Form!UnsafeTally.Value
  Set dbObject = CurrentDb
  If Not IsNull(Forms!frmDriveAudit!subfrmUnsafe.Form!UnsafeTally) Then
  strQuery = "UPDATE Unsafe " & _
    "SET UnsafeTally = Null " & _
    "WHERE UnsafeTally =" & Forms!frmDriveAudit!subfrmUnsafe.Form!UnsafeTally
    
  dbObject.Execute strQuery, dbFailOnError
  End If

I don't get any errors, but it simply doesn't work. Can anyone point me in the right direction to get this working?
 
Two minor alterations to try

first do a Debug.Print strQuery to se what is being passed to the sql string

second change the execute to DoCmd.RunSQL strQuery to set the response.

Make sure you have the DoCmd.SetWarnings True on first so that the action is echoed to the user.

This can be set to false when working ok

David
 

Users who are viewing this thread

Back
Top Bottom