Error Trap on a Zoom Box?

Kevin_S

Registered User.
Local time
Yesterday, 21:32
Joined
Apr 3, 2002
Messages
635
Hi everyone quick question -

Does anyone know if you can error trap on the closing of a zoom box which is being opened with DoCmd.RunCommand acCmdZoomBox ? I noticed that when the zoom box closes it attempts to save the field/form but I have users who don't have write permission to a form so - when they open the zoom box to read the contents and then click ok (only other option on the zoom box is cancel) it errors telling them they don't have update rights to the form.... I want them to be able to use the functionality of the zoom box without having to click cancel
:(

All help/thoughts on this is appreciated!
Kev
 
Though I have not used this particular control, I would have to suggest that if your users make a change but aren't going to save it, you need to either to an Undo on the recordset or you need to restore the original value to the record's field.
 
Hi Doc_Man -

The problem isn't that they are making a change and not wanting to save it but simply they are opening the zoom box to read the fields full content (memo field with a ton of info) and then closing the zoom box with the 'OK' button. Even though they are not making an update to the field the zoom box saves with the click of the 'OK' button and I get the error that the user doesn't have update access to the form... If they click the 'Cancel' button on the zoom box there isn't a problem but this button scares them as they think they are messing things up (when they can't even change the record) I was just trying to set up the zoom box so they didn't get the scary error (my app is fe/be split with SQL Server 2000 so they get a huge error message about the ODBC call failed... scares the begezzus out of 'em :D

If I could trap the call failed error on the close of the zoom box that would be sweet but I don't know if it is possible - I've been looking for an answer for a good 2 hours now and I'm starting to get frustrated!!

Thanks,
Kev
 
Did you build the control with a wizard? Look at the code to see why it is saving a record that doesn't need to be saved. Fix that and you fix the whole schmeer.
 
Nope, didn't build the control with the wizard simply called the zoom box with the double-click event of a text box with:

DoCmd.RunCommand acCmdZoomBox

The zoom box form is a built-in form --- I can't seem to find a way to edit it or the buttons on this form... its really quite strange!

Any other thoughts?

Thanks for the continued assistance,
Kev
 
I never would have believed it until I tried it. I use the acCmdZoomBox quite often but I never noticed that until I added a BeforeUpdate event to the text box. The message box I used in the text boxes BeforeUpdate event was being triggered if I clicked the button to zoom more than once. I added the Exit Sub command to the text boxes BeforeUpdate event and that appears to be the fix.

Private Sub Command4_Click()
tbTest2.SetFocus
DoCmd.RunCommand acCmdZoomBox
End Sub

Private Sub tbTest2_BeforeUpdate(Cancel As Integer)
Exit Sub
Rem MsgBox "Update"
End Sub

I also suggest you lock the text box to prevent anybody from modifying that field.

HTH
 
Last edited:
I would be careful of anything that cancels the update event. You don't always want it cancelled. It would be better to trap for the specific error and suppress the error message. I'm not sure where you can trap this error, so start with the Form's Error event and see if that works.
 
Hi,

As far as I can see, the ZoomBox is a modal form that works in the way a MsgBox works. That says: your code stops running until the ZoomBox is closed.
Now you can cancel the updat form the ZoomBox. i.e.:
Code:
Private Sub Knop6_Click()
  Me.txtCompaynName.SetFocus
  DoCmd.RunCommand acCmdZoomBox
  Me.txtCompaynName.Undo
End Sub
On this form: an textbox, named txtCompanyName and a Button, Knop6.
When I press the button, txtCompanyName is opened in the zoombox. Now when you change the value in the Zoombox and press OK, the code is running on and the Undo command will be triggered, so there's no change in the textfield.
With this code you can never change the value of the textbox by using the ZoomBox.
 

Users who are viewing this thread

Back
Top Bottom