SilverBean
Programmer
My scenario is that I have a form which is has button Done which the user is clicking to signal they have either made an Edit or Add - I do know which.
I would like for my Form_BeforeUpdate routine to run so the click event just does a Me.Refresh. I have also tried a variety of other "things" like DataEntry=False, Requery, Me.Dirty=False - all have given me the same results. The BeforeUpdate fires but I'm observing an undesired side effect.
Furthermore I'd like my BeforeUpdate event to do a Yes, No, Cancel. Yes would save, No - discard, Cancel allow further edits. I viewed countless posts here - not sure if others are trying to do the triple in the Before Update event, some seem to have the Undo separate. This is key, the user is under the perception that they can have a Yes, No, Cancel - and why can't they?
I really want everything in the BeforeUpdate event - for obvious reasons.
The PROBLEM is when I'm doing an Add with no records present, and then do a Done, VBA seems to have a very hard time with things. In general I think that having the undo in my BeforeUpdate event is causing problems. For example:
Private cmdDone_Click
Me.Refresh
End Sub
Private Sub Form_BeforeUpdate(Cancel as Integer)
answer = MsgBox("Yes - saves, No -discards, Cancel - continue making changes", vbYesNoCancel, "Confirm changes")
Select case answer
case vbYes
Cancel = False
case vbNo
Cancel = True
Me.Undo
case vbCancel
Cancel = True
End Select
End Sub
The Done click gives me a run time error. Which I could trap for but that just seems sloppy. Just for laughs I do the add and then I enter some data and do a manual refresh(Records, Refresh) and the update fires and works perfectly. I guess Records Refresh <> Me.Refresh.
Again this only errors during an Add with no records - which reasons not disclosed here is a concern. Once again just trying to add a little Cancel button here, this DB has just been chugging along quite well.
I stumbled across a bug on Form Close not saving data seemed maybe like something similair(i.e., a bug
), but seriously I'm not doing a form close here.
I've pretty much convinced myself that undo on a control does not work(i.e., sometextField.Undo - doesn't do anything). I've got Access 2002, Dynasets, and this is just totally useless. I even tried .Value = .OldValue does not seem to work still same error. This would be a viable solution if unlike the vbCancel (i.e. Cancel = True) if I could just erase the values in the controls I could programmatically prevent the user from doing anything else. I think there in lies the problem is that I'm trying to yank the data away while VB is trying to do an update.
Any help would be appreciated.
I would like for my Form_BeforeUpdate routine to run so the click event just does a Me.Refresh. I have also tried a variety of other "things" like DataEntry=False, Requery, Me.Dirty=False - all have given me the same results. The BeforeUpdate fires but I'm observing an undesired side effect.
Furthermore I'd like my BeforeUpdate event to do a Yes, No, Cancel. Yes would save, No - discard, Cancel allow further edits. I viewed countless posts here - not sure if others are trying to do the triple in the Before Update event, some seem to have the Undo separate. This is key, the user is under the perception that they can have a Yes, No, Cancel - and why can't they?
I really want everything in the BeforeUpdate event - for obvious reasons.
The PROBLEM is when I'm doing an Add with no records present, and then do a Done, VBA seems to have a very hard time with things. In general I think that having the undo in my BeforeUpdate event is causing problems. For example:
Private cmdDone_Click
Me.Refresh
End Sub
Private Sub Form_BeforeUpdate(Cancel as Integer)
answer = MsgBox("Yes - saves, No -discards, Cancel - continue making changes", vbYesNoCancel, "Confirm changes")
Select case answer
case vbYes
Cancel = False
case vbNo
Cancel = True
Me.Undo
case vbCancel
Cancel = True
End Select
End Sub
The Done click gives me a run time error. Which I could trap for but that just seems sloppy. Just for laughs I do the add and then I enter some data and do a manual refresh(Records, Refresh) and the update fires and works perfectly. I guess Records Refresh <> Me.Refresh.
Again this only errors during an Add with no records - which reasons not disclosed here is a concern. Once again just trying to add a little Cancel button here, this DB has just been chugging along quite well.
I stumbled across a bug on Form Close not saving data seemed maybe like something similair(i.e., a bug
I've pretty much convinced myself that undo on a control does not work(i.e., sometextField.Undo - doesn't do anything). I've got Access 2002, Dynasets, and this is just totally useless. I even tried .Value = .OldValue does not seem to work still same error. This would be a viable solution if unlike the vbCancel (i.e. Cancel = True) if I could just erase the values in the controls I could programmatically prevent the user from doing anything else. I think there in lies the problem is that I'm trying to yank the data away while VB is trying to do an update.
Any help would be appreciated.