Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239

    Creating custom zoom box

    Hi,



    I want to create a simple custom zoom box with textbox and button "OK", which would close "zoom box". I followed instructions on msdn site from MVP, but solution makes me errors :

    You can use a double click or other event to open your custom zoom form, and it can be generalized by not using anything in the zoom form that knows about the calling form. The zoom form's Load event just needs to have:
    Me.bigtextbox = Me.OpenArgs
    and an OK button that makes the zoom form invisible:
    Me.Visible = False

    The calling form's event procedure would simply be something like:
    DoCmd.OpenForm "MyZoom", OpenArgs:= Me.mytextbox, WindowMode:= acDialog
    Me.mytextbox = Forms!MyZoom.bigtextbox
    DoCmd.Close acForm, "MyZoom", acSaveNo
    So I figured out another solution, but can't fix It. I try to open a form where .Controlsource of "zoom" form's Textbox would be set to desired Textbox - but something is wrong here too. This is how I did It, placed in Load_event:

    Code:
     Text0.ControlSource = "=Forms![MyForm]![MyTextboxField]"
    Does anybody have another idea on how to create custom zoom box ?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    What errors? What is wrong? Post error message, describe what happens - error message, wrong results, nothing.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    For solution provided on MSDN site I receive error:

    error 2498 An expression you entered is the wrong data type for one of the arguments
    With my solution: form opens, "zoom box" Textbox displays text of desired Textbox, but cannot change text in It. Even closing form doesn't work anymore.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    So what is the design here? I found the source of your code and it doesn't explain much.

    You have an UNBOUND form with a single textbox set with a large font? This serves as a 'zoom' interface for memo field data entry/edit? I created this setup and tested code. Works perfect. Cannot replicate your issue.


    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    I created this setup and tested code. Works perfect.
    It worked for me too, whole 2 days

    My design: I have "Master" form, with Textbox field - which I want to zoom. So, I created a new form (named It "Zoom") and did exactly same coding as provided on MSDN. After 2 days I received error as mentioned in previous postv - I think It occured when I changed "Zoom" form's border style property to None (changing back to default didn't solve problem).

    So you think that "zoomed" control should be memo field, not Textbox ?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    The zoom control is an unbound textbox. But I called it from a textbox bound to memo field. It should work with a regular text field as well. It appears that the intrinsic zoom also works with memo or text types (I had the impression from the example only memo).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Here's a fairly simple way I worked up, ages ago, to roll your own Zoombox. Place a large Textbox (call it MyZoomBox) on your Form. Format it as you like, making the Font larger, a different color, whatever, position it as you like and assign it the same Control Source as the Control you want to expand. Yes, a Form can have two Textboxes with the same Control Source!

    Substitute the actual name of your Control to be expanded for YourTextBox, in the example.

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


    Code:
    Private Sub YourTextBox_DblClick(Cancel As Integer)
     'When you double click the field, make the MyZoomBox
     'visible and move the cursor to the beginning to
     'de-select the text  
      MyZoomBox.Visible = True
      MyZoomBox.SetFocus    
      MyZoomBox.SelStart = 0
    End Sub


    Code:
    Private Sub MyZoomBox_DblClick(Cancel As Integer)
      'Double click the MyZoomBox to close it and
      'return to your original field
      Me.YourTextBox.SetFocus
      MyZoomBox.Visible = False
    End Sub


    AS the comments indicate, you make the Zoombox visible by double-clicking the original Control you want expanded. Do whatever you want to the data, then double-click the Zoombox to close it.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    The zoom control is an unbound textbox. But I called it from a textbox bound to memo field. It should work with a regular text field as well. It appears that the intrinsic zoom also works with memo or text types (I had the impression from the example only memo).
    June, I have tested this solution in many ways now - It works again, and I cannot figure out what caused errors ? I just copied my DB, and tried again, now works ?!?


    Missinling, I have checked that solution too - before posting here. I find It quite a good solution since you can position Textbox just anywhere you want on your form, but... First problem is that I need like 7 Textboxes, so form design doesn't look nice with all hidden Textboxes. At that wouldn't be a problem at all, but unfortunally there is another bigger issue - Textbox doesn't go in front of subform control in form view, despite .Setfocus command. Can Textbox be sent in front via VBA ?

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    Apparently not. I tried manually in Design View to force textbox in front of subform. Subform control trumps other controls.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    Yes I tried that too. So unfortunate since positioning Textbox anywhere is a great feature...

  11. #11
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    I have figured out what causes problems: My Db is set to open with "Main menu" form. Via this form I open a form, where custom ZoomBox is designed. And when I want to use custom ZoomBox code, error appears. But If I open DB via SHIFT+ENTER, code works normally, even in form view. So, Is problem somewhere in code for opening my form with custom ZoomBox ??

    Here It is:

    Code:
    DoCmd.OpenForm "MyForm", acNormal, "SELECT * FROM MyForm WHERE MyField IS NULL AND MyAnotherField IS NOT NULL "

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    The WHERE CONDITION argument of OpenForm (or OpenReport) is not a full SQL statement - just the filter string. And you have it in the wrong argument.

    DoCmd.OpenForm "MyForm", acNormal, , "MyField IS NULL AND MyAnotherField IS NOT NULL"

    Also, SQL statements do not SELECT from form, they SELECT from tables and queries.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    And you have it in the wrong argument.
    I'm sorry, I don't quite understand what you're saying ? SQL wrong ? It works - If I add another comma after acNormal I get error 3075: "Synthax error in query expression SELECT * FROM etc.

    Also, SQL statements do not SELECT from form, they SELECT from tables and queries.
    My bad, example posted is wrong. I meant "SELECT * FROM MyTable WHERE MyTable_Field IS NULL AND MyTable_AnotherField IS NOT NULL"


    Did you mean that correct SQL synthax would be :

    Code:
    DoCmd.OpenForm "MyForm", acNormal,, "SELECT * FROM MyTable WHERE "MyTable_Field IS NULL AND MyTable_AnotherField IS NOT NULL" "

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,969
    No, I meant what I posted.

    You have SQL statement in the [FilterName] argument. I have never used that. I have never seen a full SQL statement used as you posted. Yet you say it works? But I thought you originally said the form is not opening properly?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    Lukael is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    239
    Ok, I tried as you said, It works too. I didn't say form is not opening properly, but as in post#11:

    - I have my DB set to open in form, named "Main Menu"
    - from that form I have CmdButton, from which I open form with this SQL statement
    - FORM that opens with this SQL statement has field where I want MyZoomBox to appear.

    If I open DB that way, I receive error as mentioned in post#3 when I want to open MyZoomBox.


    But If I open my DB with SHIFT+ENTER key, find my form which has MyZoomBox field, It works perfectly, no errors.

    And that's why I posted this SQL statement, clearly there is something wrong either with SQL for opening form, or something to do with opening DB?

    P.S.: Your suggestion for SQL didn't work too, I still receive error for MyZoomBox.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Creating Custom RibbonUI
    By lzook88 in forum Programming
    Replies: 2
    Last Post: 11-07-2015, 09:52 AM
  2. Creating a custom task schedule
    By azdjedi in forum Programming
    Replies: 4
    Last Post: 04-14-2014, 12:48 PM
  3. Creating Custom Fields
    By RudeRam in forum Queries
    Replies: 3
    Last Post: 08-01-2011, 01:09 PM
  4. creating custom switchboard
    By cnstarz in forum Forms
    Replies: 0
    Last Post: 05-25-2011, 12:18 AM
  5. Creating Custom Ribbons
    By disco_stu in forum Access
    Replies: 1
    Last Post: 07-13-2010, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums