Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 21st, 2008, 04:43 PM
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Create Secured Forms

Hello Shasur and Team,

I would like to thank you Shanmuga for your continued support...

Today I have an interesting subject that need your feedback on how to be accomplished....Grateful if you could tell us how to create secured forms... for example; if we have two forms; form1 and form2....to access contents of form2; first we will have to provide a username and password in form1 if the typed information are correct then we should be able to go to form2 else if information provided is incorrect to reject entry and display a message box to retry or cancel

Thanks and Regards....A. Borhani
 
Old January 22nd, 2008, 04:47 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

First you need to store the username and password. you can store that in a database table or hardcode in the program you want.

You can check the same against the user input in the Form1 and proceed to Form2 if both the fields are having the correct entry

You can set mask the password entered on the form by setting the value of the PasswordChar property of the textbox to "*" etc

Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old January 22nd, 2008, 02:23 PM
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default



Hello,


I have created database access table with two field one for username and one for password. Access login Database is named login.mdb....

Grateful if you could provide the full code for following...

Code..required to make excel vba form1 with txtUserName control and txtPassword control to work with login.mdb (assuming this login.mdb is saved in c:\login.mdb directory) and accept the values if matching to proceed to next form for example form2...

Thanks and Regards...A. Borhani
 
Old January 22nd, 2008, 02:49 PM
Registered User
 
Join Date: Jan 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I located following code:

Public Sub GetPassword()
    Dim PassWord As String, i As Integer
    i = 0
    Do
    i = i + 1
    i = i + 1
        If i > 3 Then


        MsgBox "Sorry, Only three tries"
     Exit Sub
End If

PassWord = InputBox("Enter Password")
Loop Until PassWord = "XXX"
MsgBox "Welcome"
End Sub

...Could you please tell me how to implement security access in my case of "form1 and form2"; if I want to go by hardcoding with above code...

Regards...A. Borhani
 
Old January 23rd, 2008, 02:06 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Here is a hint for DB

Sub Check_From_DB()

Dim Cn As ADODB.Connection '* Connection String
Dim RS As ADODB.Recordset '* Record Set

On Error GoTo ADO_ERROR


Set Cn = New ADODB.Connection
Cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\login.mdb;Persist Security Info=False"
Cn.ConnectionTimeout = 40
Cn.Open

Set RS = New ADODB.Recordset

    sQuery = "Select * From PWD_TAble Where User = '" & sUser & "' and Password = '" & sPwd & "'"

    RS.ActiveConnection = Cn
    RS.Source = sQuery
    RS.Open

    If RS.EOF = True And RS.BOF = True Then
        MsgBox "Invalid Username or password"
    Else
        Form2.Show
    End If



Application.StatusBar = False
If Not RS Is Nothing Then Set RS = Nothing
If Not Cn Is Nothing Then Set Cn = Nothing


MsgBox "Completed!!!"

ADO_ERROR:
If Err <> 0 Then
    MsgBox Err.Description
    Err.Clear
    Resume Next
    End If
End If
End Sub

Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Secured FTP File Transfer syed_sooraj Classic ASP Basics 1 December 7th, 2007 06:29 PM
How to Create SQL Forms brookhou VB Components 0 March 31st, 2006 12:20 AM
Is using DataSet secured gaurav_jain2403 ADO.NET 1 February 11th, 2006 01:05 PM
Accesing secured IIS server ichbin Beginning PHP 1 December 10th, 2004 05:19 AM
How to create forms with XSLT- urgent hums XSLT 0 September 13th, 2004 04:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.