+ Reply to Thread
Results 1 to 5 of 5

Using a class to change textbox properties

  1. #1
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Using a class to change textbox properties

    Hi all,

    I have a form with many textboxes all laid out bound to my query. I now need to perform a cross check of data within these form fields against another source. If it doesn't, I would like for the textbox to display a basic red border.

    This is all fine. I can do this with some fairly standard vba. However, I've begun to think about classes. My idea is that instead of duplicating the same code over and over again for the many textboxes i have on my form, I can use a class. I would need to turn the border of the selected textbox red (failed) and grey (passed). Except I don't really know anything about classes.

    Can someone please provide me with some code that I can study and try to implement in my project. I'm pretty competent in general VBA, but classes are new.

    Cheers

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using a class to change textbox properties

    Could you post the code that defines the logic please? - so whether it goes red or not if you were doing it without a class. That will indicate how things need to be structured

  3. #3
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Using a class to change textbox properties

    Thank for your response. The following confirms the expected details against a recordset count of another subform. This checks just one textbox, but there could be many many such checks on the same form, which would effectively mean I need to duplicate the following code (or at least pass the check to another function). Instead of doing that, I thought maybe a class would be best.


    Please Login or Register  to view this content.
    Thanks again for your input.

    Cheers

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Using a class to change textbox properties

    I dunno if you're still interested in this since it's been a while and I've only got round to looking at it now.

    Since each control is dependant on another specific control, then you aren't going to save a lot since you'll need to pass a reference into the class/object to the other control for every validation control.

    For example (this is Excel, but I suspect that Access will be similar):
    Class ControlValidator
    Please Login or Register  to view this content.
    Userform:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Using a class to change textbox properties

    Thanks Kyle. I appreciate you coming back to respond. I've give you a rep point!

    I'll apply this and see how I go.

    Cheers

+ 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. Excel VBA - set Class properties from within the class
    By TheRobsterUK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-14-2015, 09:41 AM
  2. [SOLVED] How to set class object properties
    By Tsjallie in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-18-2014, 02:58 PM
  3. [SOLVED] Change the properties of a userforn textbox based on the backcolor of a label
    By chipnputt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2014, 10:47 PM
  4. Properties in a class - can't write to them
    By Lazhal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2010, 04:16 PM
  5. Problems Setting properties of class module
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-02-2005, 09:05 AM
  6. Multidimensional Arrays as Properties in Class Files?
    By Trip in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-26-2005, 02:05 PM
  7. Custom Class and Properties
    By Rich_z in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-12-2005, 11:57 AM

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