+ Reply to Thread
Results 1 to 5 of 5

Global variable - Get a textbox value - Userform

  1. #1
    Registered User
    Join Date
    06-09-2015
    Location
    Brazil HU3HU3
    MS-Off Ver
    2007
    Posts
    5

    Question Global variable - Get a textbox value - Userform

    Well, i would like to store a textbox value (dateformat) in a global variable and then use her value to find a specific data in my DB


    so i wrote it:

    IN MODULE 1:

    'Set a global variable

    Public glbdate As Date


    'Create a function
    Public Function globaldate()

    glbdate = Format(dt_lan, "mm/dd/yyyy")

    End Function


    IN A TEXTBOX FIELD(Event afterupdate field):

    Call globaldate 'call function to get the date


    IN A COMMAND BUTTON:

    cnctnate = glbdate & manline & model 'Im trying to get the value

    IDK what's going on, but it's not working. HELP PLS!
    Thanks,
    Last edited by SamGeron; 06-12-2015 at 08:07 AM. Reason: TAGS

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Global variable - Get a textbox value - Userform

    What's dt_lan?

    Also, why do you need a global variable?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-09-2015
    Location
    Brazil HU3HU3
    MS-Off Ver
    2007
    Posts
    5

    Re: Global variable - Get a textbox value - Userform

    dt_lan is the textbox's name, i changed textbox1 to dt_lan

    I need a global variable cause i'll change the date field, but i have to store the last data to find it in my BD and replace for the new one!

    Sorry my english is horrible

    Thanks

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Global variable - Get a textbox value - Userform

    I'm not sure why you need/want a global variable, also I'm not sure what the purpose of the function globaldate is, all it seems to do is format a date.

    Where is the code to search the database located?

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Global variable - Get a textbox value - Userform

    The global variable gbldate is data type Date
    The value of the text box is a string.

    Rather than passing through the Format function, the text box value should be run through CDate function.


    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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] Refer to textbox on another UserForm via variable
    By soberguy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-02-2015, 03:58 PM
  2. VBA, Userform, Textbox: Refer to TextBox Name as a Variable
    By Brianandstewie in forum Excel Programming / VBA / Macros
    Replies: 34
    Last Post: 07-09-2013, 05:49 PM
  3. Subtract variable from UserForm TextBox
    By Nu2Java in forum Excel General
    Replies: 6
    Last Post: 10-10-2012, 10:11 PM
  4. [SOLVED] Global variable declared in Userform. Variable value is not sticking
    By timtim89 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-25-2012, 08:50 AM
  5. Setting Global Variable from a UserForm
    By agwright in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2009, 09:59 AM

Tags for this Thread

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