Close zoombox

hma54

New member
Local time
Yesterday, 20:11
Joined
Sep 19, 2007
Messages
7
Hello All, Thanks for what you do

I have a form that has 30 labels for the underlying fields. I use onClick to place a one in the table and on the label to show it's been checked, a second check removes the one, enter saves the record as long as at least one check has been made.

I have a single zoombox to enter comments that opens onclick and closes on a second click.

The enter key is set to save the record after checks have been made.

Everything works great except the enter key in the zoombox. I would like both the enter key and on click to close the textbox rather than save the record when the textbox has focus. As it is, the enter key does save the record but the box remains open. This is how the code is: (Thanks to missinglink)

Private Sub Form_Load()
'Make the textbox invisible on loading the form
Zoombox.Visible = False
End Sub

Private Sub OTHER___ENTER_COMMENT_Click()
'When you click the field, make the ZoomBox
'visible and move the cursor to the end of the text
Zoombox.Visible = True
Zoombox.SetFocus
'Zoombox.SelStart = Len(Me.Zoombox)

End Sub

Private Sub Zoombox_Click()
'Click the ZoomBox to close it and
'return to your original field
Me.OTHER___ENTER_COMMENT.SetFocus
Zoombox.Visible = False
End Sub
 
Just taking a shot at it but try reversing two lines and see what happens for you. Right now you have:

Private Sub Zoombox_Click()
'Click the ZoomBox to close it and
'return to your original field
Me.OTHER___ENTER_COMMENT.SetFocus
Zoombox.Visible = False
End Sub

Try this:

Private Sub Zoombox_Click()
'Click the ZoomBox to close it and
'return to your original field
Zoombox.Visible = False
Me.OTHER___ENTER_COMMENT.SetFocus
End Sub

HTH,
Shane
 
Thanks Shane, however, it was a miss. When opening the form, the zoombox was visible. When clicking the zoombox, it closed and produced an error- "Can't hide a control that has focus".

Weirdness- cut and pasted a line to transpose the two. After cut and pasting the line back to original and saving the change- when I loaded the form again, it loaded with the zoombox visible and the form frozen. Only thing I could do was close and open access, not the form. Had to delete it and revert to a backup.

I am very new to access- don't even know enough to be dangerous yet, but I'm thinking I have to do an onKeyPress event- not sure how to do it and don't know what effect it will have on enter key behavior throughout the rest of the form
 
Access has a built in zoom box. When you have the focus on a particular field press Shift+F2

I use the double click event and simply code

DoCmd.RunCommand acCmdZoomBox

HTH
Dave
 
Thanks Shane, however, it was a miss. When opening the form, the zoombox was visible. When clicking the zoombox, it closed and produced an error- "Can't hide a control that has focus".

Weirdness- cut and pasted a line to transpose the two. After cut and pasting the line back to original and saving the change- when I loaded the form again, it loaded with the zoombox visible and the form frozen. Only thing I could do was close and open access, not the form. Had to delete it and revert to a backup.

I am very new to access- don't even know enough to be dangerous yet, but I'm thinking I have to do an onKeyPress event- not sure how to do it and don't know what effect it will have on enter key behavior throughout the rest of the form

Hey HMA,

I was afraid it may go that way. I'm not completely new to Access but I sure don't know it like several who post here, so I thought I would try to help.

If you are wanting the 'Enter' key to do the same as the OnClick event, you can do that. First in the Forms events you would have to set the Key Preview event to "Yes", then in the textbox On Key Down event you would need to tell you code if the 'Enter' key has been pressed then I want you to execute my code.

So your code could go something like this:

If KeyCode = 13 Then
'Do what you want to do here
End If

13 is the KeyCode constant for the 'Return' key. It could also be vbKeyReturn instead of 13. If you type vbKeyReturn instead of 13, in your code, then place your cursor over it and right click and from the shortcut menu choose Definitions, this will take you to the KeyCode constants and you will see a whole list of them. Click on one and look at the bottom of the screen and you will see the numeric value for that constant.

HTH,
Shane
 
Thanks guys/girls. The built in zoombox works well. I knew it was there somewhere-didn't think about it being called a zoombox though.

Now, is there a way to edit the size of the zoombox?

Best Regards to both of you
 
Last edited:
Why not make your own....

Have a look at the double click events. They have the following components:
=Zoombox([Field where the info is coming from], "Heading you want at the top of the zoom box form")

HTH
Dave
 

Attachments

Thanks again Dave!

Dave I found your sample dbase while searching on zoombox. The system won't allow me to add any more to your already awesome reputation so you get a public ta very much instead.

If this isn't in the samples collection it should be. Cheers Barry
 
Thanks Barry, have taken your advice and submitted it to the sample Db section for approval.

Dave
 

Users who are viewing this thread

Back
Top Bottom