+ Reply to Thread
Results 1 to 6 of 6

Simple Userform question

  1. #1
    Forum Contributor
    Join Date
    11-23-2005
    Location
    Perth, Australia
    Posts
    218

    Simple Userform question

    Hi All

    This is pretty much the first time ive used userforms, and i am sure this should be simple!

    I have code which runs queries from Access, what i need to do is get a userform to pop up and ask for a password to be used in the query.
    Currently i have :
    I open the form from my code with - frmpassword.show
    I enter my password in txtpassword and click on OK

    my question is how do i then get rid of the userform and pass txtpassword to a variable i can use in my query ?

    Hope someone can help!

    Steel Monkey

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    attach code to the ok button to set variable, hide form call onther macro

    e.g

    Private Sub CommandButton1_Click()
    Dim txtPW As String
    txtPW = Me.txtpassword
    Me.Visible = False
    more code here or call another macro

    End Sub

  3. #3
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    To close your form :
    Unload Me
    To pass a variable, use field.value to define your variable

    HTH
    Cheers
    Carim

  4. #4
    Forum Contributor
    Join Date
    11-23-2005
    Location
    Perth, Australia
    Posts
    218

    Simple Userform question

    Thank you both for your response

    Then the variable will not be accessible from my module where i have my other code.

    To simplify matters, take the belwo code which is in module 1:
    Please Login or Register  to view this content.
    and this which is attached to a button in my form:
    Please Login or Register  to view this content.
    how do i get it so the password can display in the message box ?
    At the moment it doesnt, it gets lost, there isnt any communication between the form and the module where my code is

    hmm does this make sense ?

    Thanks again for your help :-)

  5. #5
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    I am not sure to fully understand ... if you do not want the password to be displayed, as it is typed : the textbox has a passwordchar property that you can set to an *

    HTH
    Cheers
    Carim

  6. #6
    Forum Contributor
    Join Date
    11-23-2005
    Location
    Perth, Australia
    Posts
    218

    Simple Userform question

    It has been done, i just declared the password.text value from the userform as a public variable then i can make use of it in my code located in a module. I am sure this is not the best way to do it, so if anyone has any bettyer ways please let me know!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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