Controls Lock/UnLock Password To Prompt only when UnLocking

Hi,
I've used Allen Browne's Locking bound control codes 
(http://allenbrowne.com/ser-56.html) to prevent overwriting data accidentally 
and it works fine.
After browsing the newsgroup, I now have this on the onClick event of 
command button called cmdLock

   Dim bLock As Boolean

   If InputBox("Enter password!", "Password Required") <> "password" Then 
Exit Sub

   bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
   Me.cmdLock.Caption = IIf(bLock = True, "&UnLock", "&Lock")
   
   Call LockBoundControls(Me, bLock)

This works ok but what happens is everytime I click cmdLock, it is prompting 
for password. I only want the password prompt to happen when I am clicking to 
UnLock but not to Lock.
How can I arrange the code above to get it only to password prompt when 
UnLocking and not when clicking to Lock.

Thanks in advance
0
Utf
3/10/2010 8:18:02 PM
access.formscoding 7493 articles. 0 followers. Follow

2 Replies
721 Views

Similar Articles

[PageSpeed] 40

Set bLock first then if it's true, ask for a password...

bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
If bLock Then
  If InputBox("Enter password!", "Password Required") <> "password" Then 
    Exit Sub
  End If
End If
Me.cmdLock.Caption = IIf(bLock = True, "&UnLock", "&Lock")
Call LockBoundControls(Me, bLock)


that wasn't that hard...

I would recommend the use of a proper exit procedure btw.  hth
-- 
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."  
-Thomas Edison (1847-1931) 



"niuginikiwi" wrote:

> Hi,
> I've used Allen Browne's Locking bound control codes 
> (http://allenbrowne.com/ser-56.html) to prevent overwriting data accidentally 
> and it works fine.
> After browsing the newsgroup, I now have this on the onClick event of 
> command button called cmdLock
> 
>    Dim bLock As Boolean
> 
>    If InputBox("Enter password!", "Password Required") <> "password" Then 
> Exit Sub
> 
>    bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)
>    Me.cmdLock.Caption = IIf(bLock = True, "&UnLock", "&Lock")
>    
>    Call LockBoundControls(Me, bLock)
> 
> This works ok but what happens is everytime I click cmdLock, it is prompting 
> for password. I only want the password prompt to happen when I am clicking to 
> UnLock but not to Lock.
> How can I arrange the code above to get it only to password prompt when 
> UnLocking and not when clicking to Lock.
> 
> Thanks in advance
0
Utf
3/10/2010 8:26:01 PM
Thanks Jack.
It was indeed so simple but I maybe still sleeping as it is early morning 
here in NZ ;-) Thanks for your help.
One thing was I wanted to happen the opposite of what the effect was on your 
suggestion so I put a "If Not bLock ......" to reverse the effect and is 
working fine. Here is the code if anyone will need it:
Dim bLock As Boolean

bLock = IIf(Me.cmdLock.Caption = "&Lock", True, False)

If Not bLock Then
  If InputBox("Enter password!", "Password Required") <> "password" Then
    Exit Sub
  End If
End If
Me.cmdLock.Caption = IIf(bLock = True, "&UnLock", "&Lock")
Call LockBoundControls(Me, bLock)
0
Utf
3/10/2010 8:34:01 PM
Reply:

Similar Artilces:

Member Server to Domain Controller
Hi How do I promote a member server running Windows 2003 Server SP2 and Certificate Services to a domain controller. Regards Use the system command dcpromo Check out the link below http://www.petri.co.il/how_to_install_active_directory_on_windows_2003.htm -- Paul Bergson MVP - Directory Services MCITP - Enterprise Administrator MCTS, MCT, MCSE, MCSA, MCP, Security +, BS CSci 2008, Vista, 2003, 2000 (Early Achiever), NT4 Microsoft's Thrive IT Pro of the Month - June 2009 http://www.pbbergs.com Please no e-mails, any questions should be posted in the NewGroups. ...

Locked Fields
On the quote log entity the fields refering to shipping addresses are all mandatory locked fields and I want to get rid of them. How do I do that? On Nov 26, 5:46 pm, DMT <D...@discussions.microsoft.com> wrote: > On the quote log entity the fields refering to shipping addresses are all > mandatory locked fields and I want to get rid of them. > > How do I do that? DMT- Settings > Customization > Quotes > Attributes > and remove the constraint from each of the fields from that section. Business Req'd , Recommended, or No Constraint. Set any/all relativ...

SetWindowPos ZOrder does not work with overlapping controls?
Hello NG, I have a problem with the ZOrder of SetWindowPos. In my CDialog, I use a bitmap CStatic to display a background picture. On that, I want to show some controls. I do it as follows: m_stcBackgroundPic.SetWindowPos(&wndBottom, 0,0,1024,496, SWP_HIDEWINDOW); m_btnDoSomething.SetWindowPos(&wndTop, 10,10,100,60, SWP_HIDEWINDOW); m_stcEditCaption.SetWindowPos(&wndTop, 10,175,150,30, SWP_HIDEWINDOW); m_ctlEdit.SetWindowPos(&wndTop, 170,175,170,30, SWP_HIDEWINDOW); Later, I show the controls with ShowWindow in the same order as above (first the background pic, then the butt...

Password Error
When setting up the email account outlook 2000 automaticaly checks the "remember password" box and the password box is blank. When I enter a password for each account,check the remember password box, and then hit apply, outlook send/recieve will work. When I close outlook I have to go through the whole process all over again because the program is not keeping the password(s). ...

outlook password #13
My outlook 2002 sometime prompt me to input network password even tick the check box to save password, do anybody know why? thx JY Take a look here, it may help: http://support.microsoft.com/default.aspx?scid=kb;en-us;290684 "Badman" <jonas@jk-networkctr.com> wrote in message news:%23zCUKmlWGHA.1204@TK2MSFTNGP04.phx.gbl... > My outlook 2002 sometime prompt me to input network password even tick the > check box to save password, do anybody know why? My Outlook 2003 (XP Pro) does the same thing. I read the article that this link connects with and followed the...

locking tabs w/macros
i have a workbook that employees use to track project progress. they enter project data into sheet 1 and vbscript macros manipulate this data and output it in various ways on worksheets 2-15. i want to lock sheets 2-15 so employees cannot enter data, but when i protect those sheets the macros are no longer permitted to work. is there a way i can prevent cell editing by USERS but permit editing by MACROS? this seems like it should be fairly obvious, but i cant figure it out. thanks in advance! Hi eric, 1) you might want to use the following instruction when protecting the sheets: ...

Creating a form for a Password
I have created a Password form that will secure another form. Once the password is entered it will open the form that has the list of reports. On the form I have a text box that accepts the user's password and I have 2 command buttons one is OK and the other is CANCEL. Can anyone tell me how to make these buttons work to open the form of reports? On Wed, 10 Oct 2007 13:52:00 -0700, mrsgwen wrote: > I have created a Password form that will secure another form. Once the > password is entered it will open the form that has the list of reports. On > the form I have a text b...

insert password using vb #2
Thank You Celtic Avenger I'll try that. Abbevill -- abbevill ----------------------------------------------------------------------- abbeville's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=976 View this thread: http://www.excelforum.com/showthread.php?threadid=26122 ...

Outlook doesnt prompt to work online/offline
OS: XP Office: 2002XP MS doesnt always prompt to work online/offline when opening outlook. The problem is that it might give u the option the 1st time you open outlook, but the 2nd and 3rd time it will not prompt you, it will just open outlook (online). I have disconneted the pda/pocket pc from the computer to make sure that it was not keeping a link between the two. I have closed outlook and killed the Outlook.exe that was running, but it still wont give the option. Anyone had this problem? Thanks ...

Is there a way to go through all the controls on a MFC dialog?
hi, I need to get through all the controls in a MFC dialog without knowing their ID at design time. That mean that the program must get the id and then get the control. Is there a better solution? One thing is for sure, I have to get the CWnd* of all of the controls on a dialog. How do I do this? thanks ThunderMusic > I need to get through all the controls in a MFC dialog without knowing > their ID at design time. CWnd* pChild = MyDialog.GetWindow(GW_CHILD); while (pChild) { // your code... pChild = pChild->GetWindow(GW_HWNDNEXT); } thanks, it works... I had the GetWin...

Release VS2005 & XP Common Controls Manifest
Hi, I have a couple questions. 1) When upgrading an MFC project from VS2003 to VS2005, the manifest options in the upgraded project settings cause Windows not to recognise the embedded manifest (as a resource) and no hence no XP controls. 2) I thought that to fix this I would create a VS2005 MFC application and look at how it sets up the manifest. Setting up a single dialog based MFC App, (with "Common Control Manifest" ticked under Advanced) I assume should create an MFC app that includes the necessary manifest and project settings - however the resulting app does not inc...

changing user password
I have a user that is not able to change her password. I set her up as a user with a temp password, thinking she would be prompted to change at first login. She was not. When she tried to force a change, it said she was not authorized. Where do I give this authorization? I am on v.10 Zach, Did she try to change the password in User Preferences => Password? -- Thanks Janakiram M.P. MCP-GP http://janakirammp.blogspot.com "Zach" wrote: > I have a user that is not able to change her password. I set her up as a > user with a temp password, thinking she would be pr...

Locked problem when using .Clear
I am using the following to Clear a group of cells; Range("AP1:AP1500").Clear however, after using this code I notice that the cells are Locked rather than Unlocked as they were originally - this then causes problems in other code I have running as the sheet is protected when distributed. Is there something elase I can do to solve the problem ? Thanks Hi, > Is there something elase I can do to solve the problem ? Post all you code because that line of code won't change the locked status of the cells. -- Mike When competing hypotheses are otherwise...

how to disable yes/no prompt when mapi is used to send email
I am using compaq insight manager which has the abiolity to sent email alert via the mapi profile with outlook for XP. The problem is a warning pops up saying thisis a VB script and may be a virus sending this email. press yes or no to send. I need to disable this so the emails can be sent automatically. Any help would be appreciated. ...

protect formulas without password
is there a way i can protect the formulas without protecting and passwording and identifying various ranges? the user accidentally enters data into a calculated cell and wipes out the formula. thank you, mike g Mike, Set the cells that the user can change to unlocked using Format, Cells, Protection, set those they can't to locked. Protect the Sheet. Robin Hammond www.enhanceddatasystems.com "work" <mike@radiant.net> wrote in message news:42140299.10B3@radiant.net... > is there a way i can protect the formulas without protecting and > passwording and identifying ...

ActiveX control is not shown correctly in Access Reports print pre
Hi All, we are developing ActiveX control's to use in MS Access. The control works fine with Access form in design mode and running mode. But in case of reports the design mode shows the control correctly but when comes to print preview mode, the size and drawing on the control is not working properly. The same control works fine with Access 2002. The problem is found to be with Access 2000. We need to enable XP theme from UxTheme.dll(Microsoft provide) if theme is avaible in the system. The drawing of theme is alo goes wrong in Access 2000 reports print preview mode. please help ...

How to Drag/Move the IE control based Application
Hi All: I am developing Dialog based application. I have placed Microsoft WebBrowser control(IE control) on main Dialog of application. On the IE control, all messages are being passed to IE control. Now problem is that I am unable to drag/move this IE Control/Dialog. Any idea about moving IE control/Dialog Please help me in this regard. Regards, Ghazanfar Ali ...

ActiveX Control error message
When I try to open any of the RMS modules (Store Operations Mgr, for example) iwhich are nstalled on my server I get the following message: "ActiveX component can't create object" I AM able to open them on both of the other computers networked to that server. I am not very tech-savvy so I'm reluctant to try anything too technical to fix this, but do any of you have something simple that would work? Or at least something that would help diagnose the problem? Thanks. -- WineGuy Hi there, It depends on what version of RMS You have installed... Anyway, there is a so...

Access2007 ON_CLICK problem on IMAGE on a TAB CONTROL
Hi All, With Access 2003 i made a form with a tab control. One one of the pages there is an image control with an ON_CLICK event assigned to it (normal vba procedure). With Access2003 the ON_CLICK is executed correctly Exactly the same DB run under Access 2007 the ON_CLICK event is ignored...no reaction at all....... This problem does not seem to occur if the image is not on a tab control Nor does it appear when i replace the image with a Button control. Can anyone tell what is hapening ? Rob, this is a known issue, but it was fixed in the service pack Microsoft released this week. You c...

Outlook Lock Up
I am trying to open my Outlook 2000. It begins to open but then locks up at the initial stages and I have to press Control, ALt and Delete and notice that it is using 96-99% of my CPU. It will not open. What can I do to open? Help? Close Outlook. Find and rename outcmd.dat to .old. (If using Windows 2000 or XP, you will need to enable searching hidden and system folders.) Once you have done so, reopen Outlook and it should open fine. You will need to rebuild any custom toolbars or customizations as the file outcmd.dat controls how the toolbars display. When it becomes corrupted, it w...

Make Bit field control value of float field
Hi. I've made bit field with the default options of yes and no: new_Q1 Then i've made a field to collect a amount of points, incase the bit is set to yes: new_Q1p. If i select the format of the bit value to "list" my script works fine. If I select "check box", it does not work. Can any one help me modyfi the script to work with the check box? Thanks Regards, Jacob Mondrup This is the script I use: ______________________________________________________________________________ var point = 0; var get_status = parseInt(crmForm.all.new_q1.DataValue); switch (get...

How to control contact sharing between Sharepoint and Outlook
Hey all, assume we have a contact list in sharepoint (SP) with 50,000 items (customers). We also have a sales force of 100 people in several groups. Now the problem: If I share the SP contact list with the sales people via Outlook, everyone of them will receive the 50,000 names. How can I control the sharing of contacts between SP and Outlook so that every sales person only receives the customers for example related to the particular sales group or limited by other parameters. Thanks in advance, Harry Hi, STC-Harry, Though this is a "misc" issue because it spans m...

Outlook locks up #13
I have appointments in Outlook 2002 going back several years. I can access old apppointments in the "Active Appointments" view, but when I try to go back more than two years in the "Day/Week/Month" view, Outlook locks up, consuming 95%+ of the CPU. I have tried a repair/detect. It had no effect. Any ideas? -- Dave Have you tried running ScanPST.EXE on your PST file to see if its corrupt? "Dapper Dave" <expurgated@gmail.com> wrote in message news:i66el2tt9mmnn4kqomjsk7hnig7g0mbqpm@4ax.com... >I have appointments in Outlook 2002 going back several ye...

forgot my password
i made an excel spreadsheet about two years ago. i am trying to open the spreadsheet now but i forgot the password that opens it. The password was set in the save as box under general options. please help Hi Forgot My Password, See Chip Pearson's notes at: http://cpearson.com/excel/password.htm I believe that some sites offer demo programs that return the initial password characters. Perhaps this will suffice to jog your memory. --- Regards, Norman "forgot my password" <forgot my password@discussions.microsoft.com> wrote in message news:7EA0C5F5-BD22-46...

CImage, CStatic (Picture Control), CObArray problem
Please help! I need to create a dialog where the user can add, remove and navigate among images - one image shown at a time. So, I created the dialog, added the buttons for adding and so on, and a CStatic picture control to display one image. The dialog has got tabs, where the image handling is on one of the tabs. The pictures are stored in a CObArray as CImages. However, absolutely nothing works with these images... I've tried just about every tip I've found in this group, at MSDN, GodeGuru and everywhere. It might be because I'm not that experienced and clever VC-programmer. So ...