[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference abbott::visual_basic

Title:Microsoft Visual Basic
Moderator:TAMARA::DFEDOR::fedor
Created:Thu May 02 1991
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2565
Total number of notes:10453

2561.0. "3426 Action Cancelled by Associated Object" by VMSNET::mickey.alf.dec.com::s_vore (Smile, Mickey's watching! [email protected]) Wed May 21 1997 16:18

Got the following scenario:

VB4.  a data control and several fields on a form.  One of the fields 
is linked to a date field in an Access table.  When the app edits a 
record with a blank date, changing it to a valid date, it's ok.  
But... when the app edits a record containnig a valid date and 
attempts to blank the date, the followin error is given:

  3426 Action Cancelled by Associated Object


The only thing in TechNet Q140309 indicates that this error is given 
with the 16-bit version.  This does not appear to be the problem 
here as:
- she's using the 32-bit version and
- she is using the Edit method before the Update method.


The button which submits the update has this code:

Private Sub CmdUpdateLot_Click()

If UpdLot = True And NewLot = False Then
   datLots.Recordset.Edit
   datLots.Recordset("Space Number") = txtspacenum
   datLots.Recordset("Available") = chkAvail
   If txtavaildate <> "" Then
        msgbox("txtavaildate not empty")
      datLots.Recordset("Next Available Date") = txtavaildate
   Else
        msgbox("txtavaildate IS empty")
      'txtavaildate.Text = Null
      datLots.Recordset("Next Available Date") = Null
   End If
End If
datLots.Recordset.Update
datLots.Recordset.Bookmark = datLots.Recordset.LastModified
UpdLot = False
NewLot = False
End Sub



Ideas?  Suggestions?


T.RTitleUserPersonal
Name
DateLines
2561.1suggestionXSTACY::PATTISONA rolling stone gets the wormThu May 22 1997 07:457
Well, thats a Jet 2.5 error message, which suggests that the Access
Database must be an old one (V2.0)

Converting it to a more recent version might be one thing to try.


2561.2VMSNET::mickey.alf.dec.com::s_voreSmile, Mickey&#039;s watching! [email protected]Thu May 22 1997 08:3731
Actually, I've done further research and believe that the error 
message is misleading at best ("Communism is just a red herring").

I've created yet another even smaller test project.  An Access(95) 
database with a single table that has one text, one date, and one 
numeric field.  Plop a data control and three bound fields on a 
form (vb4 or vb5).  Move around, update data all you'd like. Make 
the text field blank and move to the next record, no problem. Make 
the numeric field blank and move to the next record, no problem. 
Make the date field blank, though, and you'll get the same error.

In an attempt to get around this, I've tried testing for an empty 
field.  My problem is this -- how to express an empty date?  My 
customer wants to allow an empty field rather than using a bogus 
hard-coded ancient-history value; what should I put in place of 
DateValue("1/1/1900") below?

Private Sub cmd_update_Click()
    If IsDate(t2_date) Then
        Data1.UpdateRecord
    Else
        MsgBox ("invalid date")
        t2_date = DateValue("1/1/1900")
        Data1.UpdateRecord
    End If
    Data1.Recordset.Bookmark = Data1.Recordset.LastModified
End Sub


-Steven

2561.3I think...XSTACY::PATTISONA rolling stone gets the wormThu May 22 1997 09:039
Its trying to set the date to a zero-length string (where a NULL is what
you wanted). So what you need to do is over-ride the bound control (only
when its empty) by going directly to the recordset field and setting that
to NULL, before updating.

-Dave


2561.4oh well. hey, thanks for the info!VMSNET::mickey.alf.dec.com::s_voreSmile, Mickey&#039;s watching! [email protected]Thu May 22 1997 12:116
ooh, ick.  That's basicly the "solution" that I've been able to find 
via dejanews's usenet archives as well this morning... one would have 
though that MS would have a more elegant solution.

-Steven