+ Reply to Thread
Results 1 to 7 of 7

Userfrom textbox .TextAlign issue

  1. #1
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Userfrom textbox .TextAlign issue

    Hi there,

    I have another small issue with a userform that I cannot seem to solve. I have a userform that opens in two different ways.

    1. Initial opening the form is empty and you fill in all fields required. When you do this the .TextAlign center works correctly:

    Userform.jpg

    2. On other occasions the userform is pre filled with previously entered data on initialisation and this occurs:

    userform1.jpg

    When I click in the textbox on the userform the number in the textbox snaps back to center but initially, and without clicking in the box, the number is aligned to the right and partially obscured.

    Its not a big issue but it is annoying and I cannot seem to correct the issue. All the relevant textboxes have TextAlign properties set to center:

    Textalign.jpg

    and I also run this code on initialisation of the userform:

    Please Login or Register  to view this content.
    Any suggestions on how to solve this one?

    Cheers,
    Marcus

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Userfrom textbox .TextAlign issue

    Never seen a form do this before.

    If there aren't many of them you could possibly solve it with a textbox change event that sets the alignment so when the control is populated.
    That way it would all happen when you load the form with data already in.

    BSB

  3. #3
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Re: Userfrom textbox .TextAlign issue

    Hi BSB,

    Thanks for the reply, I tried adding a line to the change event but no joy. I did just solve my problem though by adding this to the code:

    Please Login or Register  to view this content.
    I do have lots of little issues with this program that I will be posting over the next week or two, what is the etiquette with asking lots of questions? Also if it is a more complex issue that is hard to explain with text and pictures is it possible to post a screen shot video of the problem?

    Cheers,
    Marcus

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Userfrom textbox .TextAlign issue

    Nice fix.
    Would like to see the form doing this though as I've never seen it happen before and I'm interested in what's causing it.

    As for etiquette, feel free to ask all the questions you want. We're here to help. If there are a number of questions that are related to the same project then you can put them in a single thread. Obviously if you have many many questions then you may want to spread them out over a number of threads as overly long posts don't seem to attract much attention.

    I don't think the forum has the functionality for posting videos I'm afraid.

    BSB

  5. #5
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Re: Userfrom textbox .TextAlign issue

    Thanks BSB,

    I placed the userform into a new workbook and commented out most of the code to it opens and closes, not sure if this will be usefull to you but feel free to have a look at the code. If you see anything that can be improved please let me know. I'm not much of a coder and when I started I never used Option Explicit but managed to get something together that worked.

    Thanks for the response re etiquette, a single thread is probably a good idea for a few smaller issues and a individual threads for any larger issues.

    Cheers,
    Marcus
    Attached Files Attached Files

  6. #6
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Userfrom textbox .TextAlign issue

    Under what circumstances does the form open pre-filled? That's the bit of code I'm interested in.


    There is little point in me trawling through the 3k+ lines of code and pointing out bits that could be improved upon if it all works for you. A quick look through reveals no immediate concerns (unlike much of the VBA that comes my way in my work life! )

    What's important in coding is that it works and is written in a way that means you will understand it when you come back to it in the future for bug fixing / amending.
    We all have our own styles of writing code. Some people like to go for the smallest number of lines possible, some go for maximum efficiency. I go for plain simple code that will be understood by the people I ultimately hand the project over to meaning they can maintain them with little to no involvement from me.

    BSB

  7. #7
    Forum Contributor
    Join Date
    06-29-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2016 (Office 365)
    Posts
    137

    Re: Userfrom textbox .TextAlign issue

    The process is:

    The form is used to enter information into a navigation log for a helicopter. Initially the log has not been created and when the userfrom first opens the user will enter all the information and then select the 'Create Navlogs' button which then creates the navlog. The process to creating a navlog is copying a blank navlog form and then entering all the information from the userform into it. Once you press the 'Create Navlogs' button all the information on the userform is also stored on a worksheet called 'Misc'.

    Now when you have created your Navlog and you decide you want to change something on it there is a button on the form called 'Change'. When you press this button it opens the userform again and all the information from the 'Misc' worksheet is reloaded into the userform on initialisation. This is when the .TextAlign does not work correctly, only when you click in the textbox will it snap back to center.

    Most of the code that does this is in the initialisation sub however I do have a module that has some code in it that is called that is not in the userform code.

    There are a lot of moving parts in this program which makes it hard to nail down in one post.

    Cheers,
    Marucs

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Populate TextBox value from Pivot Table based on other UserFrom fields
    By AndyE in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2018, 10:59 AM
  2. Userfrom Textbox doing a Search based on Worksheet Name on the same Workbook
    By choleb in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-11-2013, 08:32 AM
  3. [SOLVED] TextBox Control on a Userfrom
    By jeff_kaufman in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-18-2013, 06:37 PM
  4. Aplly a autofilter on a userfrom spreedsheet based on a textbox value
    By cyclone77 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2012, 08:46 PM
  5. Help Pre-Populating userfrom into unknown textbox
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2012, 03:34 AM
  6. [SOLVED] Userform TextBox TextAlign Problem-Bug?
    By Jason Moser in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2006, 01:29 PM
  7. Listbox textalign
    By R4gtl in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2005, 08:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1