SilverBean
Programmer
This is going to start to sound like a previous post I just made but I need
to provide some background information for you folks that might've missed it
before I move on to the focus of this particular thread.
Background:
I create a new table with 2 fields a text field(defaults used and not
changed) and a traditional primary key, autonumber field.
I design a form which has the following code you can imply 2 buttons from
this code an Add and Done. The Done merely attempts to make the form save
itself - simple concept really.
Private Sub cmdAdd_Click()
DoCmd.GoToRecord , , acNewRec
End Sub
Private Sub cmdDone_Click()
Me.Refresh
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim answer As VbMsgBoxResult
answer = MsgBox("Yes, No, Cancel", vbYesNoCancel, "Title")
If answer = vbYes Then
Cancel = False
End If
If answer = vbNo Then
Me.Undo
Cancel = True
End If
If answer = vbCancel Then
Cancel = True
End If
End Sub
I've seen enough to have no confidence in Access VBA at least as far as
saving records is concerned. Problem is I double click on the form(to open
it and use it). Do an Add, type something in the text field and then do a
Done, I respond No and Access gives me a runtime error which says "Run time error '2455' You entered an expression that has an invalid reference to the propert |." and the Debugger is at the Me.Refresh line.
This occurs with Access 2002 DB. Redo same on an Access 2000 DB (under Access 2000) starting from creating table - works fine that machine. Even bring to the Access 2002 machine that 2000 DB works fine.
Then something happens and either all my DB's start working OR the 2000 DB will not work any more.
Not work = run time error message similair to above, same place but sometimes "No Current Record is cited"
Something happens? is this connected to Debug mode?
I think this might be connected with Debug mode. I go in and modify Code any
piece of code really(even if not connected to above just type silly characters Save
and now all databases 2000 and 2002 will respond with the runtime error
when they are opened and the sequence attempted.
Two issues (1) Have I explained enough here to allow somebody to reproduce, understand, and/ or
believe - probably not, and (2) I've seen enough to have "no confidence".
This might be a flaky situation where the table has no records, maybe a bug
with Access connected with closing and not saving data or maybe I've got a
flaky installation - all or none of the above doesn't matter. No confidence.
Onto THIS TOPIC:
I've got my own save routine which will fire at the click of the Done, all
my data checking confirmation is done there so I can explicitly do a Save
only if thats what the user wants. In this case the BeforeUpdate merely
checks to see if my save routine has set a variable and then allows the save
or not - Fine.
(1) If the use has snuck out of my form (in reality this will be a child on
a Parent form - a viable concern). The BeforeUpdate will fire and I can
Cancel if myUpdate variable is not set. HOWEVER the best I can do is tell
the user to select Done. Does anybody have a better solution? I can deal
with a DBMS that can't save records, but in this day and age any viable
computer solution that has to tell the user to do something ought to just do
it for them. For example, I need a method of running an event, procedure or
function AFTER the BeforeUpdate(which has been cancelled) - if I run it
during BeforeUpdate I think I'm back where I started. No timers please.
(2) Does it make sense that I do not need the Cancel = True in the vbNO
case above? If I put Cancel = False all versions of Access seem to be fine with
this, that is no runtime errors....ever and no NULL records are put into the
table. I can live with this and it almost makes sense but I'd like somebody
to confirm this and possibly explain.