Multi-loginForm to access Database

Collymore

New Member
Joined
Nov 23, 2021
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
hey

I'm name is Collymore and I'm not very good with excel and vba and
oh yes first time asking question on mrexcel.com but I visit this website everyday to learn

But i need to grant particular user from excel vba (login form) to access its own user database(ms access)

Ability
The user must have ability to delete and append data into access database
and view entire database on worksheet

I have the login form as follows

Credentials:
are saved in the excel worksheet (username and password)

Multiform code:

Option Explicit
Public attempt As Integer
Private Sub cancelBtn_Click()
username_input.Text = ""
password_input.Text = ""
End Sub

Private Sub exitBtn_Click()
Dim iExit As VbMsgBoxResult

iExit = MsgBox("Confirm if you want to Exit!!!", vbQuestion + vbYesNo, "Registration System")

If iExit = vbYes Then
MsgBox "Enjoy your day!!!", vbOKOnly + vbCritical
Unload Me
End If
End Sub

Private Sub loginBtn_Click()
Dim username As String
Dim password As String
Dim username_1, password_1 As String

'Store Range(A2,F2,C2) cells '
username = Sheets("Sheet1").Range("A2").Value
username_1 = Sheets("Sheet1").Range("A3").Value
password = Sheets("Sheet1").Range("F2").Value
password_1 = Sheets("Sheet1").Range("F3").Value

If (username_input = username Or username_input = username_1 And password_input = password Or password_input = password_1) Then
MsgBox "Login Success!!", vbOKOnly + vbQuestion
Unload Me
Application.Visible = True

Else
If (username_input <> username Or username_input <> username_1) Then
MsgBox "You have entered an invalid username or email.", vbOKOnly + vbExclamation
ElseIf (password_input <> password) Then
MsgBox "You have entered incorrect password.", vbOKOnly + vbExclamation

'Locks after 3 tries'
Else
If attempt < 3 Then
MsgBox "Invaild login credentials. Please try again.", vbOKOnly + vbCritical, "Invaild login Details"
attempt = attempt + 1
Else
MsgBox "You have exceeded the maximum numer of login attempts.", vbOKOnly + vbCritical, "Invalid Credentials"
Unload Me
ThisWorkbook.Close saveChanges:=False
Application.Visible = True
attempt = 0

End If
End If
End If
End Sub

Private Sub UserForm_Initialize()
Me.username_input.Value = ""
Me.password_input.Value = ""

Me.username_input.SetFocus
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub

from login:

if username and password is true then
open userform2 for that particular logged in user


userform2(delete/append/import) database

does the following:
1. update(Append) particular column and row data entires from excel to access database table of the particular user(from loginform)
2. delete particular column and row entries from excel to access database table
3. Import/ view entire columns and rows of the database in the listbox

the problem is i dont have any idea to plan userform2
please help!!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,215,377
Messages
6,124,597
Members
449,174
Latest member
chandan4057

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top