Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Password on InputBox
Eirik 

12 years ago
Ok, here is the kode if you dont find it on the link:

    Public sPassword As String
    Public gMsgTitle As String
    Public gMsgType As String
    Public gMsgText As String
    Public gStatusText As String 'Status bar text used in Application.Echo method
    ' API set A:
    ' Used by the callback process (TimerProc) to hook into
    ' the InputBox window
    ' Ref: http://pub13.ezboard.com/fvisualbasicexplorervbtips.showMessage?topicID=314.topic
    Private Declare PtrSafe Function FindWindow Lib "user32" Alias _
    "FindWindowA" (ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long
    
    Private Declare PtrSafe Function FindWindowEx Lib "user32" Alias _
    "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, _
    ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr
    
    Public Declare PtrSafe Function SetTimer& Lib "user32" _
    (ByVal hwnd&, ByVal nIDEvent&, ByVal uElapse&, ByVal _
    lpTimerFunc&)
    
    Public Declare PtrSafe Function KillTimer& Lib "user32" _
    (ByVal hwnd&, ByVal nIDEvent&)
    
    Private Declare PtrSafe Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As LongPtr, ByVal wMsg As LongPtr, _
    ByVal wParam As LongPtr, lParam As Any) As LongPtr
        
    ' Constants for API set A
    Const EM_SETPASSWORDCHAR = &HCC
    Public Const NV_INPUTBOX As Long = &H5000&

Public Function TimerProc(ByVal lHwnd&, ByVal uMsg&, _
    ByVal lIDEvent&, ByVal lDWTime&) As Long
    Dim lTemp As Long
    ' This function allows for a mask character on an inputbox
    ' ' Usage (Replace anything between [] with valid names from your project):
    ' From a form or module:
    ' 1. Declare a Long variable
    ' 2. Call the timer function: [variable] = SetTimer([form].Hwnd, NV_INPUTBOX, [elapsed time], AddressOf [function name])
    ' 2b. Example usage from a form: lTemp = SetTimer(Me.Hwnd, NV_INPUTBOX, 1, AddressOf TimerProc)
    ' 3. Create your InputBox as usual
    
    Dim lEditHwnd As Long
    
    ' Find a handle to the InputBox window, then to the textbox
    ' the user types in (Known as "Edit")
    ' ' **This part is VERY important, here is how the FindWindowEx call should look:
    ' **Only change the parameters that are enclosed in [ ] in the following example
    lTemp = FindWindowEx(FindWindow("#32770", "[gMsgText]"), 0, "Edit", "")
    lEditHwnd = FindWindowEx(FindWindow("#32770", gMsgTitle), 0, "Edit", "")
    
    ' Send the mask character to the target InputBox when the user types
    ' The mask character in this sample is the Asc("*") - the "*" can be changed
    ' to whatever you like.
    
    Call SendMessage(lEditHwnd, EM_SETPASSWORDCHAR, Asc("*"), 0)
    ' Destroy the timer object when done (The user clicks OK or Cancel from the InputBox)
    KillTimer lHwnd, lIDEvent
End Function






Private Sub OpnAdm_Click()
  
     Dim pResponse As String
     Dim lSalesPersonID As Long
     Dim lEditHwnd As Long
     Dim lTemp As Long
     Dim strPasswd As String
     gMsgTitle = "Begrenset Omr de"
     gMsgType = vbOKOnly + vbInformation
     gMsgText = "Tast inn passord"
     Beep

     lTemp = SetTimer(Me.hwnd, NV_INPUTBOX, 1, AddressOf TimerProc)
     sPwd = InputBox(gMsgText, gMsgTitle)
     MsgBox "the password you entered was: " & strPasswd


    If strPasswd = "" Or strPasswd = Empty Then
        Exit Sub
    End If

    If strPasswd = "yslg53481" Then
        DoCmd.OpenForm "frmBatchReg"
    Else
        MsgBox "Beklager, du har ikke tilgang til denne delen av programmet", vbOKOnly, "Sikkerhetssjekk"
        Exit Sub
    End If

    
End Sub


This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/15/2026 9:07:30 AM. PLT: 0s