Consulting

Results 1 to 13 of 13

Thread: expansion (bound) textfield in continous subform

  1. #1
    VBAX Regular
    Joined
    Jan 2016
    Posts
    45
    Location

    expansion (bound) textfield in continous subform

    Hello,

    I have a form, and in that form is a continues subform.

    One field in that subform is a bound textbox. I would like that if this box has the focus, the box expand till 10 cm (twixel?) Standard is the widht of this field 3 cm. (twixel?)

    Offcourse when I open the mainform the textbox in the subform is widht 3 cm. I searched the internet over how to do the expand of this box, but I cannot find a solution to do the expansion.


    Any help will be valued,

    Regards, Ton from Holland

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    372
    Location
    Exactly what have you tried and what happens? Setting Width property works for me.

    This would require also moving any controls sitting at right of textbox.

    Consider using ZoomBox feature. https://support.microsoft.com/en-us/...8-a2c2e83dcedf
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    VBAX Contributor
    Joined
    Nov 2020
    Location
    Swansea,South Wales,UK
    Posts
    113
    Location
    I did something similar for a combo
    Private Sub cboFoodIDFK_GotFocus()
    'Debug.Print Me.cboFoodIDFK.ColumnWidths
    TempVars("FoodWidth").Value = Me.cboFoodIDFK.Width
    'Debug.Print "GotFocus " & TempVars("FoodWidth").Value
    Me.cboFoodIDFK.Width = "8000"
    Me.cboFoodIDFK.ColumnWidths = ExpandCombo(Me.cboFoodIDFK.ColumnWidths)
    End Sub
    
    
    Private Sub cboFoodIDFK_LostFocus()
    'Debug.Print "LostFocus " & TempVars("FoodWidth").Value
    Me.cboFoodIDFK.Width = TempVars("FoodWidth").Value
    Me.cboFoodIDFK.ColumnWidths = ShrinkCombo(Me.cboFoodIDFK.ColumnWidths)
    End Sub
    Public Function ExpandCombo(pstrWidths As String) As String
    Dim strWidth() As String, strNewWidth As String
    Dim i As Integer
    
    
    strWidth() = Split(pstrWidths, ";")
    'For i = 0 To UBound(strWidth)
    '    Debug.Print strWidth(i)
    'Next
    strWidth(1) = CStr(Val(strWidth(1)) * 1.5)
    
    
    For i = 0 To UBound(strWidth)
        strNewWidth = strNewWidth & strWidth(i) & ";"
        'Debug.Print strWidth(i)
    Next
    'Debug.Print strNewWidth
    ExpandCombo = Left(strNewWidth, Len(strNewWidth) - 1)
    'Debug.Print "Expanding " & ExpandCombo
    'MsgBox ExpandCombo
    End Function
    
    
    Public Function ShrinkCombo(pstrWidths As String) As String
    Dim strWidth() As String, strNewWidth As String
    Dim i As Integer
    
    
    strWidth() = Split(pstrWidths, ";")
    'For i = 0 To UBound(strWidth)
    '    Debug.Print strWidth(i)
    'Next
    strWidth(1) = CStr(Val(strWidth(1)) / 1.5)
    
    
    For i = 0 To UBound(strWidth)
        strNewWidth = strNewWidth & strWidth(i) & ";"
        'Debug.Print strWidth(i)
    Next
    ShrinkCombo = Left(strNewWidth, Len(strNewWidth) - 1)
    'Debug.Print "Shrinking " & ShrinkCombo
    'MsgBox ShrinkCombo
    End Function

  4. #4
    VBAX Regular
    Joined
    Jan 2016
    Posts
    45
    Location
    Hello June7,

    I was familiar with the option ZOOM, when I use the option, the popup box can I change the borderline?
    Is there no other way to do this with VBA?
    Like:
    Private Sub Omschrijving_GotFocus()
        Me.Omschrijving.Width = 6500
        Me.Omschrijving.SetFocus
        Me.Omschrijving.SelLength = 0
        Me.Omschrijving.SelStart = Nz(Len(Me![Omschrijving]), 0) + 1
      End sub
    
    And:
    
    Private Sub Omschrijving_LostFocus()
        Me.Omschrijving.Width = 1440
    End sub
    This code was written in the subform, didd not work.

    When you look,
    https://www.youtube.com/watch?v=NMWksevolhc
    you know what I mean.

    By the way, I use access 2016
    Last edited by Aussiebear; 10-01-2024 at 02:19 PM. Reason: Added code tags to supplied code

  5. #5
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    372
    Location
    "did not work" means what - error message, wrong result, nothing happens?

    Works for me in subform.

    I've never utilized ZoomBox. What is borderline?
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    add a "special" key (shortcut) to invoke your Zoombox.
    it is annoying if you are jumpinng from record to record and
    the zoombox keeps on popping on those hops.

  7. #7
    VBAX Regular
    Joined
    Jan 2016
    Posts
    45
    Location
    Hi june7,

    When I go with my mouse, the arrow keys or tab key to the textbox in my subform, (onfocus) the text (is longer than the width of the textbox).

    What happens is that de textbox not expand but my cursor goes to the end of my description, so far, so good.

    But Its not what I want. I want to see the whole description what inside the textbox (visual from beginning till the end of the description)

    not expand (lost focus)

    Met access is het leuk


    expand (on focus)

    Met access is het leuk werken, moet ik wel even nadenken



    Ill hope its clear for you, otherwise I dont know to explane my question.

    Greetings

  8. #8
    you can also add an unbound textbox on the subform to show the Description.
    Attached Files Attached Files

  9. #9
    VBAX Regular
    Joined
    Jan 2016
    Posts
    45
    Location
    Hi arnelgp,

    I did open your DB, and I was surprised to see saw that your subform was presented with form header en form footer.
    Mine subform has no header and footer section, just a datasheet. Its is my mistake that wrote in my earlier post that my subform was a continious form. My apologies. It was not the solution I was looking for, but still it works fine and I used it in my DB.
    I think perhaps it cannot be done to expand a textbox in a datasheet itself. (I don’t know)

    I created in my mainform a textbox “Omschrijving” with the control source from my table. The control I made was is 15 cm width.
    So your direction to make it work in my DB was for me the solution.

    Thank you !!

  10. #10
    here is another demo. it will expand the Description column on the subform when you click or the column has focus.
    it will go back to it's original column width when you leave the column.
    open MainForm2 and see the code on Load event of subDatasheet subform and the Click, GotFocus, LostFocus of Description column.
    Attached Files Attached Files

  11. #11
    VBAX Regular
    Joined
    Jan 2016
    Posts
    45
    Location
    Hi VBAX Expert

    I did open your DB, ther was a message
    SECURITY PROBLEM “Microsoft blocked the performance of the macro’s, the source is not to be trusted.

    So I did still opened your DB, It was not working. I don’t how to shut down the security problem.

    TonC

  12. #12
    VBAX Regular
    Joined
    Jan 2016
    Posts
    45
    Location
    Hello VBAX Regular,
    Your genius, It works!!!!! I solved the security problem, put your code in my subfrm datasheet

    Many thanks, this what I looked for.
    Regard Tonc

  13. #13
    when you download any file from the internet, always right click on and on it's Property, tick Unblock.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •