VBA code to password protect and entry field?

Hi all! Here's an interesting project. 

In one of my forms in an acess DB, I have a text entry box. Now,  I don't
want just anyone to be able to type garbage into this text box. I also do not
want to hide or lock it. I need to use it now and again.

IS there some code snippet I can use to that will prompt for a password to
unlock the text field?

An example would be IF one were to click on the text field, A prompt would
come up for a password. You enter the password and the text box would now be
active to acept typing. Otherwize the text box needs to be greyed out and
null (not active).

Thoughts on this?

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201002/1

0
chris23892
2/22/2010 7:57:11 PM
access.modulesdaovba 1670 articles. 0 followers. Follow

2 Replies
2583 Views

Similar Articles

[PageSpeed] 13

There are a few events you could use to trigger a prompt for a password, On 
Dirty, On Change, and On Got Focus.  On Dirty is probably your best bet if 
the text box and the form its on are tied to a field and table.  On Change 
works even if it isn't, but it's triggered once per character entered, so you 
might want to build in a time delay.  On Got Focus will be triggered every  
time you click in the box or tab to it.

Of the three of them, On Got Focus would be my first choice.

Private Sub TextBox1_GotFocus
     Dim strPassword as String
     
     If Inputbox("Please enter the password:") <> strPassword Then
        SomeOtherControl.SetFocus
        TextBox1.Locked = True
    End If
End Sub


Please let me know if this helps,
CJ

"chris23892 via AccessMonster.com" wrote:

> Hi all! Here's an interesting project. 
> 
> In one of my forms in an acess DB, I have a text entry box. Now,  I don't
> want just anyone to be able to type garbage into this text box. I also do not
> want to hide or lock it. I need to use it now and again.
> 
> IS there some code snippet I can use to that will prompt for a password to
> unlock the text field?
> 
> An example would be IF one were to click on the text field, A prompt would
> come up for a password. You enter the password and the text box would now be
> active to acept typing. Otherwize the text box needs to be greyed out and
> null (not active).
> 
> Thoughts on this?
> 
> -- 
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201002/1
> 
> .
> 
0
Utf
2/22/2010 9:14:01 PM
fantastic...I'll give it a try and let you know. thanks for the insight. very
helpful information

CJ Ardash wrote:
>There are a few events you could use to trigger a prompt for a password, On 
>Dirty, On Change, and On Got Focus.  On Dirty is probably your best bet if 
>the text box and the form its on are tied to a field and table.  On Change 
>works even if it isn't, but it's triggered once per character entered, so you 
>might want to build in a time delay.  On Got Focus will be triggered every  
>time you click in the box or tab to it.
>
>Of the three of them, On Got Focus would be my first choice.
>
>Private Sub TextBox1_GotFocus
>     Dim strPassword as String
>     
>     If Inputbox("Please enter the password:") <> strPassword Then
>        SomeOtherControl.SetFocus
>        TextBox1.Locked = True
>    End If
>End Sub
>
>Please let me know if this helps,
>CJ
>
>> Hi all! Here's an interesting project. 
>> 
>[quoted text clipped - 11 lines]
>> 
>> Thoughts on this?

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201002/1

0
chris23892
2/22/2010 9:23:04 PM
Reply:

Similar Artilces:

How to Stop Worksheet_Change event from running during code execution
I'm sorry If I've asked this before but I can't find an answer to it. I have the following 2 events in a worksheet module.... Private Sub Worksheet_Change(ByVal Target As Excel.Range) Private Sub Worksheet_SelectionChange(ByVal Target As Range) I run some codes, either in UserForms or general procedures that make changes to this worksheet. Q. Is there a way to by-pass those two events somehow? As an example I have a uf that comes up if a cell is selected in that sheet. So I need those worksheet_Change events to work at that point. But then, the uf does some stuff like inputing ...

VBA code to say Yes or No if any VBA code is present in ActiveWork
Using XL 2003 & 97 Would like hit Ctrl+Shift+V and have an answer either yes or no as to the presence of Any VBA code in the Active Workbook. I do know that about the VBA editor/Explorer or to press the Run Macro button and get a list from various sources . I would like to stay at the keyboard and process a series of macros including one to let me know if I even need to evoke the VBA explorer. TIA Dennis There is no bootstrap macro to tell you whether you have macros or not. If there were there would be no limit to virus writers. --- HTH, David McRitchie, Microsoft MVP - Excel ...

Payout reason codes
Can someone point me to where in the database the payout reason codes are stored? thanks, Store Ops Manager, Database, Reason Codes, Type = Payout "Jason" wrote: > Can someone point me to where in the database the payout reason codes are > stored? > > thanks, Thanks. What I meant (and asked poorly) was if I wanted to design a custom report to show that info where would I need to look? Thanks, "Wendy_I" wrote: > Store Ops Manager, Database, Reason Codes, Type = Payout > > > > "Jason" wrote: > > > Can someo...

Custom PWA fields show no data in PWA
Hi, My company has recently started to use Team Foundation Server and it is being used to track softwer development progress. The project related information is transferred to Project Pro and Project server 2007. There are several custom fields provided by Team system including work item ID which uniquely identifies the scenario, bug or task. However when I try to view these fields in PWA the box is empty. The custom field heading is corect. I have exported the custom fields from Project to Project server but this has not helped. Can anyone help with this? -- Regard...

Sort several workbooks using code
I am looking to run code that will sort several workbooks even when they are closed. The code would be executed via a master workbook which will also be sorted. Is this possible? I'm not aware of sorting records in a CLOSED workbook, but what you can do is this. Create some button on the master workbook and let it open the other workbook, sort the other workbook and close the other workbook. Accompanied with Application.ScreenUpdating (but also depending on the amount of records) you will hardly notice the sorting actions. Does this help ? -- Regards; Mark ...

Print, Merged Cells, and VBA
Hello I'm looking for a code that will help me with a print job for a worksheet. There are a lot of merged cells and a lot of "IF"s to be used in the VBA for range selection. Thanks in advance, Sarr ...

Use VBA to update Access table or Query from Excel
Can I use VBA to update Access table or Query from Excel? Thanks in advance Hi Leungkong, > Can I use VBA to update Access table or Query from Excel? Of course, using ADO or DAO. See: http://www.erlandsendata.no/english/index.php?d=envbadacexportado Regards, Jan Karel Pieterse Excel MVP http://www.jkp-ads.com Hi Jan, Thanks. I think ADO is what I want. But I am not only want to export from excel to access. I want to edit some data in access table. For example, Access has a table "ProductList" I want to use Excel to call the product by "Pro...

VBA and Scheduled task in Outlook
Hi, how can I: a) pull the query from somewhere and send it by e-mail automatically. E.g. I want to take a temperature table from http://www.wunderground.com/history/airport/EHAM/2009/7/10/DailyHistory.html?req_city=NA&req_state=NA&req_statename=NA where 2009/7/10 is the date of yesterday put it into an e-mail and send it automatically each day at 8 o'clock? b) if this is not possible, how can I send an e-mail with the attachment c:\Documents\query20090710.xls each day at 8 o'clock? my boss wants this automatized, I know how to write the VBA code for Excel, but don'...

How get rid of reveal codes?
How get rid of reveal codes? the symbols are all over my document!! How do I get rid of them?? Try:- ALT + F9 If my comments have helped please hit Yes. Thanks. "Christa" wrote: > How get rid of reveal codes? the symbols are all over my document!! How do > I get rid of them?? Ctrl+* or Ctrl+Shift+8. See http://word.mvps.org/FAQs/Formatting/NonPrintChars.htm -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "Christa" <Christa@discussions.microsoft.com> wrote in mes...

vba select field
Hi, having a button on a form, is it possible to select only some fields (all from the same table) of the current record instead of all fields? I've tried this code: RunCommand acCmdSelectRecord RunCommand acCmdCopy Forse dipende dei dati nel record. but it selects ALL fields in the form. Thank you. Remigio hi, On 10.04.2010 18:01, remigio wrote: > having a button on a form, is it possible to select only some fields > (all from the same table) of the current record instead of all fields? > I've tried this code: > > RunCommand acCmdSelectRecord &...

VLOOKUP in VBA
On the worksheet I can insert in a cell =VLOOKUP(C5, Hobokee.xls!AcsLow, 2) and it works perfectly, looks up the value in column 2 of the range named AcsLow in the same workbook. But elswhere I want in a macro to lookup the same table and assign the result to a variable BalAmt. BalAmt = VLOOKUP(AccNum, Hobokee.xls!AcsLow, 2) does not work. It gives a function not defined error on Hobokee. If instead of Hobokee I put Workbooks("Hobokee"), it gives function not defined error for VLOOKUP which it changes to VLookup. I have been overVLOOKUP in the Help file and see nothing wrong. W...

Excel VBA/Macro programming for beginners
Hi all, I know a bit VB 6.0 programming. Will it help me to write exce vba/macro(same thing?).can anybody help me by providing some fre websites where i can have informations/codes for VBA/macro. Please tell me how could i make a *command Button * in a cell in th excel sheet -- sdebu_200 ----------------------------------------------------------------------- sdebu_2000's Profile: http://www.officehelp.in/member.php?userid=430 View this thread: http://www.officehelp.in/showthread.php?t=118812 Posted from - http://www.officehelp.i Try David McRitchie's "getting started with mac...

Turn pc speaker on/off with vba code
Is this possible? Thanks I found something here on how to do it withVBScript. You can probably modify it to work in VBA http://www.pcreview.co.uk/forums/thread-1468591.php -- HTH, Barb Reinhardt "David" wrote: > Is this possible? > Thanks Thanks Barb I'll have a go (I need to improve my web searching skills) "Barb Reinhardt" wrote: > I found something here on how to do it withVBScript. You can probably modify > it to work in VBA > > http://www.pcreview.co.uk/forums/thread-1468591.php > -- > HTH, > ...

Password-Passport Problems
I am trying to move my money account from a computer that uses Money2002 to a computer that uses Money2001. When I use it on the present computer I sign in using MSN Passport ID. When I try to open it in the new computer that uses 2001 it asks for my password. It will not accept my password and I can't figure out how to use MSN Passport ID to open the data. I'll be so thankful to anyone who can help me.... You cannot open a money 2002 file with Money 2001. The password thing is just Microsoft's way of telling you can't do that. Zach On 8/13/04 2:42 PM, in article 5...

How do I protect specific cells from changes in Excel?
Please can someone help me. How do I protect specific cells from changes in Excel? I have a spreadsheet that I would like users to only be able to change certain cells, the others need to be protected from change Go to Format>Cells. On the Protection tab, uncheck the "Locked" box for any cell you want to be editable. After you protect the document, the user will only be able to edit the cells you unlock. "LarryH" <LarryH@discussions.microsoft.com> wrote in message news:2E8A5FD8-A990-4181-9842-19B007C88F71@microsoft.com... > Please can someone help me. ...

Loading a Form from VBA
Hi all, I'd like a module to open and load a form in my Access 2003 database... How can I do this? Use the OpenForm method. Look in the Help file for details. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Mike" <michael.leon.schwartz@gmail.com> wrote in message news:1184770076.109526.207900@o11g2000prd.googlegroups.com... > Hi all, I'd like a module to open and load a form in my Access 2003 > database... How can I do this? > On Jul 18, 10:58 am, "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com&g...

Can I to populate "Web page" AD field onto GAL ?
In AD, I have the "Web page" field. Imagine I want to make this field visible in GAL, so that people can look up that specific webpage when double clicking a specific username in GAL (it sounds silly, but that's a request from my internal folks). Can you tell me again how I populate fields from AD onto GAL (to be visible via Outlook) ? I can't remember... Exch2003SP1. "Marlon Brown" <nomail@brown.com> wrote: >In AD, I have the "Web page" field. >Imagine I want to make this field visible in GAL, so that people can look up >that spec...

Excel and VBA
I am very interested in learning more about using VBA in office, especially Excel. Can you post some resources (online, books, etc) that can be used to help learn about using Visual Basic in office. Thanks! Here's a good place to start: http://www.contextures.com/xlbooks.html Does that help? *********** Regards, Ron XL2002, WinXP "Bob Sinclair" wrote: > I am very interested in learning more about using VBA in office, especially > Excel. Can you post some resources (online, books, etc) that can be used to > help learn about using Visual Basic in office. >...

VBA Customization
Is there a way to get the name of the current company through VBA in Great Plains 8.0? Thanks for all your help. open GreatPlains. Add the current window, it will add the Toolbar then add fields choose the company name on the top left after the user id. >-----Original Message----- >Is there a way to get the name of the current company through VBA in Great >Plains 8.0? > >Thanks for all your help. > > > >. > Thanks. I tried, but I couldn't add company name to the field list. It opens up the login screen instead. Any thoughts? Thanks again. "ger...

Run VBA without show
I want excel to run the VBA code without showing me what it is doing. Which code should i use for that? Sub RunWithoutShow() Application.ScreenUpdating = False 'Paste the vba code here 'end of code 'Change screenupdating property to true Application.ScreenUpdating = True End Sub I hope this helps... Selva V Pasupathy For more on Excel, VBA, & other Resources Please visit: http://socko.wordpress.com You may also (inserting into quote from code example bellow from Socko) Use Application.Visible property to hide the application entirely Sub RunWithoutShow() Appli...

Form Controls vs VBA controls
I am new to VBA so just finding my feet, can anyone help me with th differences between an excel control (i.e. one from the form toolbox lets say a checkBox and a vba checkBox? From trying the two controls the I have noticed is that you canno capture the change event of the VBA checkbox in the code module, it ha to be done via the sheet (i.e. checkbox on sheet1, code goes in chang event on sheet1) the control is placed on, is this correct? What woul you do if you have three sheets with the same controls just differen data, do you really have to code the control 3 times? The excel control ho...

How do I insert a "save date" / "last edit date" field in footer
I want to insert "save date" / "last edit date" in my visio diagrams. However, currently Visio does not provide such option. I tried with insert field, but that seems not working -- i.e. when I inserted "last edit date" and saved the document, then on the next date, without modifying the document, I opened the document and printed; then I got the next day's date printed in the field "last edit date". So any input / suggestion? Thanks The choices for what you can place in a header/footer is limited. If the Visio drawing is the same size a...

Checking for Existing Field in Table
Ok I have the following code: Function CheckIfFieldExist(TableName As String, FieldName As String) As Boolean On Error GoTo CheckIfFieldExist_Err ' Function that check if a field exist in the table ' Return True if exist , and False if doesn't exist Dim I As String CheckIfFieldExist = True I = Application.CurrentDb.TableDefs(TableName).Fields(FieldName).Name Exit Function CheckIfFieldExist_Err: If Err = 3265 Then CheckIfFieldExist = False Else MsgBox Error End If End Function this is the other half of the code: 'Late If Chec...

Referencing a ComboBox in VBA
Hi, I am using Excel 2007. I want to run some code in my Workbook_Open() Sub that fills a combo box on one of my Worksheets (I will call it myCombo on mySheet). I tried the following code and it did not work: myCombo.Clear myCombo.AddItem "Item One" myCombo.AddItem "Item Two" myCombo.AddItem "Item Three" I assume that the problem is that within the Workbook_Open() Sub, the reference to myCombo is not valid. Can anyone tell me if/how I can get a valid reference to myCombo (on mySheet)? Thanks in advance, Paul Kraemer -- Paul Krae...

color-coding cells and more
Excel 97 / W98 Two easy questions. Is there a way to color-code a cell based on a condition, BUT not using Visual Basic Editor? That is, I want to change a cell based on a condition using the =IF(a,b,c) format. In the status bar, I have choices of SUM, Average, and a few others. Always opens with SUM as the default option. Can I change the default to 'Average?' -- Replace the AT in address Statistics convinces us we are in a minority. Probability convinces us we are psychic. Old guy wrote: > Is there a way to color-code a cell based on a condition, BUT not > ...