473,769 Members | 5,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trouble creating login in excel

9 New Member
i have created a database using excel and i have to set a security level i have written all of the vba code correctly i think but it just does seem to work properly. here is the code below if anyone could point out any problems with it would be much appreciated.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Login_Click()
  3. Dim name, password, found, loops
  4.   found = 0
  5.   loops = 0
  6.   name = Range("Username").Value
  7.   password = Range("Password").Value
  8.   Worksheets("Data").Visible = True
  9.   Worksheets("Data").Select
  10.   ActiveSheet.Range("A1").Activate
  11.   While ActiveCell.Offset(loops, 0).Value <> "" And found = 0
  12.     If Username = ActiveCell.Offset(loops, 0).Value Then
  13.       If password = ActiveCell.Offset(loops, 1).Value Then
  14.         found = 1
  15.       End If
  16.     End If
  17.     loops = loops + 1
  18.   Wend
  19.   If found = 0 Then
  20.     Worksheets("Login").Select
  21.     Worksheets("Data").Visible = True
  22.     MsgBox ("Logon Failed")
  23.     Worksheets("Lowlev").Visible = False
  24.     Workbooks("Unit10assisgnment.xls").Close SaveChanges:=False
  25.   End If
  26.   Worksheets("Lowlev").Visible = True
  27.   Worksheets("Lowlev").Select
  28.   ActiveWindow.DisplayWorkbookTabs = True
  29.  
  30. End Sub
  31.  
Nov 15 '06 #1
2 1956
willakawill
1,646 Top Contributor
i have created a database using excel and i have to set a security level i have written all of the vba code correctly i think but it just does seem to work properly. here is the code below if anyone could point out any problems with it would be much appreciated.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Login_Click()
  3. Dim name, password, found, loops
  4.   found = 0
  5.   loops = 0
  6.   name = Range("Username").Value
  7.   password = Range("Password").Value
  8.   Worksheets("Data").Visible = True
  9.   Worksheets("Data").Select
  10.   ActiveSheet.Range("A1").Activate
  11.   While ActiveCell.Offset(loops, 0).Value <> "" And found = 0
  12.     If Username = ActiveCell.Offset(loops, 0).Value Then
  13.       If password = ActiveCell.Offset(loops, 1).Value Then
  14.         found = 1
  15.       End If
  16.     End If
  17.     loops = loops + 1
  18.   Wend
  19.   If found = 0 Then
  20.     Worksheets("Login").Select
  21.     Worksheets("Data").Visible = True
  22.     MsgBox ("Logon Failed")
  23.     Worksheets("Lowlev").Visible = False
  24.     Workbooks("Unit10assisgnment.xls").Close SaveChanges:=False
  25.   End If
  26.   Worksheets("Lowlev").Visible = True
  27.   Worksheets("Lowlev").Select
  28.   ActiveWindow.DisplayWorkbookTabs = True
  29.  
  30. End Sub
  31.  
Hi. Perhaps the thing that is most evident here is the last part of your code
Expand|Select|Wrap|Line Numbers
  1. If found = 0 Then
  2.     Worksheets("Login").Select
  3.     Worksheets("Data").Visible = True
  4.     MsgBox ("Logon Failed")
  5.     Worksheets("Lowlev").Visible = False
  6.     Workbooks("Unit10assisgnment.xls").Close SaveChanges:=False
  7.   End If
  8.   Worksheets("Lowlev").Visible = True
  9.   Worksheets("Lowlev").Select
  10.   ActiveWindow.DisplayWorkbookTabs = True
  11.  
Can you explain what this line does?
Workbooks("Unit 10assisgnment.x ls").Close SaveChanges:=Fa lse
Nov 16 '06 #2
squidge1990
9 New Member
whne the incorrect details have been entered it will close the workbook and i choose whether i want to save the changes that have made to the workbook before it closes.

i have to set to false so it doesnt save the changes that have been made when the wrong password and username are entered.
Nov 16 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7024
by: Jeremy Langworthy | last post by:
Hi I am trying to create a MS Excel format CSV but I can't figure out how to get the line feed/carriage return/new record working properly. I am nding each line/record with these characters: "\r\n" but the Excel file just loads all the field in one row as if it doesn't recognise these characters. These are the headers I am using to create the file:
1
4148
by: Andy | last post by:
Hi, Please help, I'm getting desperate. Any ideas warmly welcomed! I'm trying to read from a basic excel file (1000 or so rows from column A) but am having problems. The code I am using is: Declare @Return Int SET NOCOUNT ON Exec @Return= .. 'READ_XLS', 'EXCEL', 'Microsoft.Jet.OleDB.4.0' , 'e:\jsbackup\RACodes.xls',
5
3387
by: Guy Incognito | last post by:
Hello, I've written an asp.net application that creates Excel documents. It works by creating an excel document in XML format. But I wonder if I'm reinventing the wheel. I know that there are ways to read and write Excel files with ADO, but as far as I can tell, it doesn't provide the flexibility I need. I need to be able to generate tabs, cell formatting, formulas, etc.
9
8900
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save this out of an XML file or Excel Template file. Next I need to convert a dataset to xml and try and transform this data into the users xml file..........i've seen a few things on this but havent had much success...
0
1297
by: Ronald Snelgrove | last post by:
To All: I am a newbie to VB.net and am writing an application in VB.net in which I successfully create an Excel sheet, tabulate and format some data on a sheet titled "summarySheet". A difficulty arises when I try to define where a page break should be. I need to fit a landscape table on one sheet. I thought that "telling" Excel where the vertical page break is would cause it to reduce the zoom factor, thus fitting the table on one...
7
2701
by: Paul | last post by:
Hi I have created an excel file download feature within a .net application using Microsoft Office XP primary interop assembly for excel. I was just wondering if anyone knows if you can also embed excel formulas in the excel download, for example a running total on a column, thanks. -- Paul G Software engineer.
0
1324
by: ketz | last post by:
How do i create a user login for a excel spreadsheet through a userform. I've seem to be able to get a password working but that only lets one passwrod in and its only the password. Ideally what i'd like is a user name and a password with multiple user so that the workbook can be accessed by various user through their own password and username. This is so then i can make a seperate login for the other members of staff who do different jobs in...
10
8159
by: Hendri Adriaens | last post by:
Hi, I'm trying to automate the creation of an excel file via COM. I copied my code below. I read many articles about how to release the COM objects that I create. The code below runs just fine and excel is closed. But there are some commented lines: //xlSeries.XValues = xlWs.get_Range("B2", "B4"); // makes com objects, but which...
2
3981
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: D:\original\CaseStudy-2-5\CaseStudy\Day02\exercise>asant database Buildfile: build.xml env-user: prop-user: set-user:
0
9583
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10039
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6668
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.