473,490 Members | 2,495 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

save record using password protected cmd button

49 New Member
I am trying to make available a way to save "new" old data to the database. If someone forgets to enter their verification, i need a way for the boss to be able to enter that information at a later time. The database is set to be realtime, so the fields on the form are controlled by the user clicking a save button which automatically fills the date field and they cannot adjust the date. But when someone forgets to verify their work, we have holes that need to be filled in... right now i just go into the corresponding table and add it, but i have 60+ tables and its a little tedious for the "boss" to do. I want a button on each form that he can use, that allows him to update, but no one else - via his password.

here's the catch - since I have 60+ tables, I want the button to ask for his password, and verify it with the admin table which has his password in it, if the password matches save the record and open a new record.

I thought I had it, it seems to save it, but when i step thru to make sure its working this error comes up when it hits DoCmd.Save:

Run-time error '2487':

The Object Type argument for the action or method is blank or invalid.

here's my code
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdManualUpdate_Click()
  2. Dim strPasswd
  3.  
  4.     strPasswd = InputBox("Enter Password", "Restricted Form")
  5.  
  6.     'Check to see if there is any entry made to input box, or if
  7.     'cancel button is pressed. If no entry made then exit sub.
  8.  
  9.     If strPasswd = "" Or strPasswd = Empty Then
  10.         MsgBox "No Input Provided", vbInformation, "Required Data"
  11.         Exit Sub
  12.     End If
  13.  
  14.     'If correct password is entered open Employees form
  15.     'If incorrect password entered give message and exit sub
  16.  
  17.     If strPasswd = DLookup("PWD", "AdminLogin") Then
  18.         Form.SetFocus
  19.         DoCmd.Save
  20.         DoCmd.GoToRecord , , acNewRec
  21.  
  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.  
It will also throw the following error when it hits the DoCmd.GoToRecord:

Run-time error '2046'
The command or action 'GoToRecord' isn't avaialbel now.

yet if I don't have the break points it actually goes to a new record like i wanted it to. I just don't understand why its throwing errors during the step thru, and seemingly does what i want it to.


I also noticed... if i don't use the correct capitalization, it still lets it go thru, if I use the wrong word it is fine... is there a way to make it be case dependent?
Jan 12 '15 #1
4 1313
jforbes
1,107 Recognized Expert Top Contributor
My guess is it's the Setfocus during Debug throwing an error, Access can't handle it. It's not you, it's Access. Access has trouble updating/using the UI while in Debug. Visual Studio has this trouble as well. Either step over that during debugging or put your breakpoint on line 19.

You'll want to use StrComp to consider case when comparing strings. (You can thank Rabbit for that link.)
Jan 12 '15 #2
jforbes
1,107 Recognized Expert Top Contributor
There is another way to approach locking down button on a Form that might be a lot easier for both you and your Boss. You could have the Button (or any other control on the Form) enabled or disabled based on what User is logged into the Windows computer.

You can use the function provided at http://access.mvps.org/access/api/api0008.htm to get the currently logged in User. Then on either the OnCurrent or OnLoad of the Form enable/disable controls based on user. You could even take it even further and compare it against a user table if you want.

The end result would be that the prompt for password as well as all the messages would go away and the button would only be enabled for valid users.
Jan 12 '15 #3
sooli
49 New Member
I made a work around that turned out to be golden! I have the table's appear in datasheet mode at the bottom of the form if the correct password is entered as a result of a button click. This sub-form is set to not visible until the password is entered, so no one can see it except for the admin & the Boss loved it!

Boss didn't want the users to have to log in to the database... no idea why...but that is what he wanted so that is what he got... I know this limits my ability to lock things down...and I explained that to him. He is under the impression I believe, that folks won't know enough about Access to do anything harmful... so password/protecting wasn't necessary for the average user.
Mar 6 '15 #4
Brilstern
208 New Member
sooli,

While yes, your boss is somewhat right, it doesn't keep the average user from learning how to bypass security controls. A quick search in Google can be used to bypass even the more complex security controls.I would strongly suggest you browse Rabbit's article on Database Security and twinnyfo's article on user permissions, and the articles linked in twinnyfo's as well. Although I understand certain situations require less or more security, being informed nonetheless is a the only way to be one step ahead. Hope you take some time to browse their expertise.
Mar 6 '15 #5

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

Similar topics

6
25236
by: Geert-Pieter Hof | last post by:
Hello, My VB 6.0 application read and writes data from and to a MS Excel workbook, using the Microsoft.Jet.OLEDB.4.0 provider. Now I want to protect the Excel workbook with a password, but I...
22
2203
by: xmp333 | last post by:
Hi All, I am trying to hide my JavaScript source. The method I chose was to keep all the important source in a password protected folder, and then use a SRC="folder/script.js" to include it...
9
2188
by: Ben Allen | last post by:
Hi, I want to create a password protected page to administer my site from (the news is read from a mySQL database and I have created a PHP form to as a GUI to do this). I thought of...
2
1546
by: RICHARD BROMBERG | last post by:
I am building a password protected ASP web site. (http://www.allscrewedup.org) When you go to this site there is a link in upper left corner (VIP) that takes you to a Logon Screen. The user...
3
1350
by: fred | last post by:
Hi all, I am new for using C# to develop web app. I made a web project which was password protected by using form mode authentication. in my login page ,I added one button of "add a user" which...
2
10264
by: voroojak | last post by:
Hi How can i put save record and next record in one button. in my save record i put the calculation of the text boxes. i have a total field that the sum of the other field is in there and it wil be...
2
1193
by: veer | last post by:
Hi can any one help me by giving the method how i can save a file on a computer which is on My LAN and also Password protected if i login the destination computer first and then save the file...
1
1243
by: denniswong288 | last post by:
Hi, My website has PDF documents that's available for registered users to view online (through my site) only. Currently, I can't find any solutions to prevent users from downloading/"save-as"...
1
2323
by: sknaina | last post by:
Hi Eveybody, I've a main form with a continuous subform based on 'DonorTranSmasterF' & 'DonorTranSdetailsF' , both tables are linked via 'DonorTransiD' field. I know & learn , How to save record...
17
10247
by: RachelleB | last post by:
I'm trying to find the best way to do the following 1. From a main form (my own switchboard) press a command button to open a form 2. Before the form opens a Input Box appears asking for the ID...
0
7108
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,...
0
6967
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...
0
7181
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...
1
6847
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...
0
5445
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,...
0
3078
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
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...

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.