CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Fri, 15 Aug 2025 09:11:10 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20080422072821
location: https://web.archive.org/web/20080422072821/https://www.daniweb.com/code/snippet320.html
server-timing: captures_list;dur=0.638450, exclusion.robots;dur=0.023546, exclusion.robots.policy;dur=0.010297, esindex;dur=0.012144, cdx.remote;dur=7.753512, LoadShardBlock;dur=119.908240, PetaboxLoader3.datanode;dur=40.434223, PetaboxLoader3.resolve;dur=33.318032
x-app-server: wwwb-app203
x-ts: 302
x-tr: 158
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app203; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Fri, 15 Aug 2025 09:11:11 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Tue, 22 Apr 2008 07:28:20 GMT
x-archive-orig-server: Apache/2.2
x-archive-orig-x-powered-by: PHP/5.1.6
x-archive-orig-set-cookie: bblastvisit=1208845987; expires=Wed, 22-Apr-2009 07:28:20 GMT; path=/; domain=.daniweb.com
x-archive-orig-set-cookie: bblastactivity=0; expires=Wed, 22-Apr-2009 07:28:20 GMT; path=/; domain=.daniweb.com
x-archive-orig-cache-control: private
x-archive-orig-pragma: private
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Tue, 22 Apr 2008 07:28:21 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Fri, 23 Jun 2006 13:08:22 GMT", ; rel="prev memento"; datetime="Mon, 24 Mar 2008 18:05:59 GMT", ; rel="memento"; datetime="Tue, 22 Apr 2008 07:28:21 GMT", ; rel="next memento"; datetime="Fri, 29 Aug 2008 22:24:25 GMT", ; rel="last memento"; datetime="Sun, 24 Dec 2023 00:41:41 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 51_3_20080422070705_crawl105-c/51_3_20080422072556_crawl104.arc.gz
server-timing: captures_list;dur=0.955068, exclusion.robots;dur=0.031075, exclusion.robots.policy;dur=0.013741, esindex;dur=0.013921, cdx.remote;dur=32.108823, LoadShardBlock;dur=82.576923, PetaboxLoader3.datanode;dur=122.631880, load_resource;dur=173.609585, PetaboxLoader3.resolve;dur=100.345494
x-app-server: wwwb-app203
x-ts: 200
x-tr: 396
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
Password protect indiviual buttons on the Access Switchboard - visualbasic
Password protect indiviual buttons on the Access Switchboard
•
•
•
•

What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 316,081 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,176 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
This is the coding needed to password any button on any switchboard from used in Access Database
'NOTE: The sample code in this article uses Microsoft Data 'Access Objects. For this code to run properly, you must reference 'the Microsoft DAO 3.6 Object Library. To do so, click References 'on the Tools menu in the Visual Basic Editor, and make sure 'that the Microsoft DAO 3.6 Object Library check box is selected. 'Using Code to Password Protect a Form 'By using code, you can prompt for a password when a user 'opens a form or a report. If the correct password is entered, 'the form or the report is opened. 'The following example shows you how you can password protect 'the Orders form in the sample database Northwind.mdb: '1. Start Access and then open the sample 'database Northwind.mdb. '2. Press ALT+F11 to start the Microsoft Visual Basic editor. '3. On the Insert menu, click Module. '4. In the module sheet, type the following procedure: Public MyPassword Public Function KeyCode(Password As String) As Long ' This function will produce a unique key for the ' string that is passed 'in as the Password. Dim I As Integer Dim Hold As Long For I = 1To Len(Password) Select Case (Asc(Left(Password, 1)) * I) Mod 4 Case Is = 0 Hold = Hold + (Asc(Mid(Password, I, 1)) * I) Case Is = 1 Hold = Hold - (Asc(Mid(Password, I, 1)) * I) Case Is = 2 Hold = Hold + (Asc(Mid(Password, I, 1)) * _ (I - Asc(Mid(Password, I, 1)))) Case Is = 3 Hold = Hold - (Asc(Mid(Password, I, 1)) * _ (I + Len(Password))) End Select Next I KeyCode = Hold End Function '5. Press ALT+F11 to return to Access. '6. In the Database window, under Objects, click Tables, 'and then click New. '7. In the New Table dialog box, double-click Design View. '8. Create a new table as follows: 'Table: tblPassword 'Field Name: ObjectName Data Type: Text Field Size: 50 'Field Name: KeyCode Data Type: Text Field Size: '25 Input Mask: Password Table Properties: tblPassword 'PrimaryKey: ObjectName '9. Open the tblPassword table and then enter the following data: 'ObjectName: Orders (ObjectName is the name of the form you 'want to go to) 'KeyCode: 2818 '10. Create a new form in design view and save the form 'as frmPassword. '11. Add a single textbox to frmPassword called Text0, 'and a command button called CheckPassword. '12. Set the Input Mask property of Text0 to "PASSWORD" '(minus the quotation marks). '13. Add the following code to the OnClick Event of 'the CheckPassword button and then save the form: If IsNull(Forms!frmPassword!Text0.Value) Then MsgBox "You cannot enter a blank Password. Try again." Me!Text0.SetFocus Else MyPassword = Me!Text0.Value DoCmd.Close acForm, "frmPassword" End If '14. Open Switchboard Table and Print it off You will need 'this information '15. Open the Main Switchboard form in Design view. 'Then open the VB Editor. '16. Apply the following code where indicated in the code. 'The thing you need to remember is the SwitchboardID 'is 0 for default and the ItemNumber is 2 for the 3rd button 'on the main switchboard. By changing these in the 'IF statement you can direct which button to have 'the Password on. Select Case rs![Command] ' Go to another switchboard. Case conCmdGotoSwitchboard Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument] 'Below is the modified code I put into the Switch board Dim Hold As Variant Dim tmpKey As Long Dim I As Integer Dim rs1 As DAO.Recordset Dim db As DAO.Database Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument] ‘ Below is where you set the button If Val([ItemNumber]) = 0 And Val([SwitchboardID]) = 2 Then DoCmd.OpenForm "frmPassword", acNormal, , , , acDialog Hold = MyPassword Set db = CurrentDb Set rs1 = db.OpenRecordset("tblPassword", dbOpenTable) If rs1.NoMatch Then MsgBox "Sorry cannot find password information. Try Again" Cancel = -1 ' Move to the switchboard page that is marked as the default. Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' " Me.FilterOn = True ElseIf Not (rs1![KeyCode] = KeyCode(CStr(Hold))) Then MsgBox "Sorry password does not match Key Code." & _ "Try again.", vbOKOnly, "Incorrect Password" Cancel = -1 ' Move to the switchboard page that is marked as the default. Me.Filter = "[ItemNumber] = 0 AND [Argument] = 'Default' " Me.FilterOn = True End If rs1.Close db.Close End If '17. Close and then save the Switchboard. '18. Open the Switchboard and select your button it shoud 'open the frmPassword 'Notice that the Orders form opens. The KeyCode that is generated 'by PASSWORD matches the KeyCode in the tblPassword table, 'and is dependent on the case of the letters in the password entered. '19. Close and then reopen the Orders form and then 'type PassWord when you are prompted for a password. 'Notice that you receive the message: 'Sorry you entered the wrong password. Try again. 'The Switchboard does not open and is redirected to 'Default Switchboard because the password procedure is case-sensitive. '20. To determine what the corresponding KeyCode is for 'a particular string, type the following in the Immediate 'window and then press ENTER: '?KeyCode("TestString") 'The earlier example returns 5864. '21. To hide the tblPassword table in the Database window, 'right-click the tblPassword table, and then click Properties. 'In the Properties window, click to select the Hidden check 'box, and then click OK.
Comments (Newest First)
tongs | Newbie Poster | Mar 15th, 2007

•
•
•
•
:rolleyes:
Drisconsult | Newbie Poster | Jun 13th, 2006

•
•
•
•
How can the password, "PASSWORD" enhance security? Surely the code should allow the use of any text for a password, or am I being dumb today?
Regards
Terence
Regards
Terence
jayp2002 | Newbie Poster | Nov 16th, 2005

•
•
•
•
yeaq good work.but am getting an eror on this peice of line what do i do
Public MyPassword Public Function KeyCode(Password As String) As Long
Public MyPassword Public Function KeyCode(Password As String) As Long
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)
- Today's Posts
- Unanswered Threads
Related Features
DANIWEB FEATURE INDEX
ADVERTISEMENT
STATISTICS