473,763 Members | 5,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to program command button in Access Macro to require a password

20 New Member
I created a simple macro to open a form with several command buttons on the form. On one of these buttons I want to require a password for access. I am not a programmer. What do I need to do to make this happen?

Thanks for your help
Oct 21 '10 #1
3 7887
Rixxe
7 New Member
You really should google in the first instance, as many of the answers you want are avaliable.

None the less:

Open the switchboard form in design view and select the command button.
Select the On Click event and choose Event Procedure from the drop down list. Click on the ellipses (...) to enter the code window.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOpenEmpForm_Click()
  2.  
  3. 'Attached to On Click event of cmdOpenEmpForm
  4.  
  5.     Dim strPasswd
  6.  
  7.     strPasswd = InputBox("Enter Password", "Restricted Form")
  8.  
  9.     'Check to see if there is any entry made to input box, or if
  10.     'cancel button is pressed. If no entry made then exit sub.
  11.  
  12.     If strPasswd = "" Or strPasswd = Empty Then
  13.         MsgBox "No Input Provided", vbInformation, "Required Data"
  14.         Exit Sub
  15.     End If
  16.  
  17.     'If correct password is entered open Employees form
  18.     'If incorrect password entered give message and exit sub
  19.  
  20.     If strPasswd = "Graham" Then
  21.         DoCmd.OpenForm "frmEmp", acNormal
  22.     Else
  23.         MsgBox "Sorry, you do not have access to this form", _
  24.                vbOKOnly, "Important Information"
  25.         Exit Sub
  26.     End If
  27. End Sub
  28.  
You will notice the line If strPasswd = "Graham" Then . This contains the required password that will be required when attempting to open the form.

This can be changed to any password that you wish.


(Note: This information is originally from, and can be found at: http://www.databasedev.co.uk/button_security.html)
Oct 21 '10 #2
cambar
20 New Member
Thanks very much. Worked great.
Oct 21 '10 #3
Rixxe
7 New Member
You're welcome.
Oct 22 '10 #4

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

Similar topics

1
3483
by: Jason L. | last post by:
Here's the scenario. Using a campaigning applicaion for an eNewsletter. It writes to an Access table. I have an ASP web page that writes to another table. I chained 3 Access queries together into a Macro to copy that data to the campaigning table, give a numeric identifier to that record, and then delete all records with that identifier (in the 2nd table). This will keep the ASP > Access table clean. The campaigning software allows for...
2
15726
by: dskillingstad | last post by:
I'm trying to assign a custom value to a textbox. Here's what I have. I've created a module and "default value" code for a textbox which generates a custom auto-number (yyyy-0000) when a New Record button is clicked. The code checks the table for the highest value and then assigns 1 and inserts the value. I have a second text box which needs the same type of custom auto-number which has to be generated from a second command button. ...
2
5622
by: Darren | last post by:
Hi, I have a command button which has a macro running in it. The macro on the click event, runs to ensure that certain values in a form are valid, (e.g. the textboxes are not null) and after the macro runs, an update query would run... the problem is that how can i ensure that the update query would only
4
17373
by: Alex Chun | last post by:
How can I program a command button on a form to bring up the standard "Find and Replace" dialog on click? Separate but related: how do you run menu commands (e.g. "Edit" "Find") from VB? Thanks in advance! Alex
2
17720
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report from the database but I am not sure how do I put a command button and associate a macro with that using C#. Can anyone help me?? Thanks in advance. Senthil
1
2401
by: yello | last post by:
Hi All, I have a MS Access macro which needs to be scheduled in the Task Scheduler. I am using the following link to schedule the macro "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "D:\Formatting Script.mdb" /x "Schedule_Macro" The macro is scheduled and ran fine when I used my User Id in the Schedule Task.
0
1982
by: sclinkenbeard | last post by:
I want to use a command button in Excel and have the VBA macro to open a PDF document. Does anyone know the VBA code to do so? It is easy opening word doc and another excel program but not sure how to do so with a pdf document. Do I need to tell the macro to open Adobe first? Any assistance is helpful. Thank you.
4
14589
by: mld01s | last post by:
Hi all!! I need help, I have been stuck for a few days on this one. I am trying to open an excel table from a command button in Access. The excel table has an auto_open macro, that is supposed to run everytime I open excel. When I navigate to the excel file, and open it, it autoruns the macro with no problems. When I go from Access hit the command, the excel table opens with no problem, but the macro does not auto run on start. Here is...
1
6198
MitchR
by: MitchR | last post by:
Good Morning Folks; I have a question that is pretty far fetched but here goes nothing... I am looking to find a way to insert a macro into an Excel command button located in an Access VBA generated Excel spreadsheet from an Access Module. I can create the spreadsheet, button, and I have the macro to insert into command button. But I am not sure how to assign the macro to the button in the access module. Set xlApp =...
0
9564
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...
1
9938
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
9823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8822
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...
0
6643
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
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3528
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.