Input Box Help with Code

JTQ911

Registered User.
Local time
Today, 13:33
Joined
Jul 26, 2007
Messages
83
Hi everyone. First off, thanks for any help. I have an input box that asks for a password and then checks and locks a checkbox. Its on a bunch of forms that Quality Assurance is going to use as their digital signature to sign off on forms. I asked this yesterday, how can I mask the password as its typed in by the user. Some people say you can, but I found this code posted that supposedly allows you to do this but I am not sure how to apply it to my code. Can somebody please help me.

http://www.access-programmers.co.uk/forums/showthread.php?t=150644

^^ The code to mask an input box

MY CODE:

Private Sub Command1_Click()
If InputBox("Enter Password", "Quality Assurance") = "Accept" Then
Me!chkapproval = True
Me!chkapproval.Visible = True
Me!chkapproval.Locked = True
Else
Me!chkapproval = False
End If
End Sub


Private Sub Command4_Click()
If InputBox("Enter Password", "Quality Assurance") = "Reject" Then
Me!chkreject = True
Me!chkreject.Visible = True
Me!chkreject.Locked = True
Else
Me!chkreject = False
End If
End Sub
 
Create a new code module and paste all of the code into it. Make sure to compile it so that there are no errors. Then simply do something like:

If InputBoxDK("Enter password") = "MyPassword" then
- do some code -
End if
 
So I just create a new module, paste all that in there, and go from there. If some of the code is red after copying and pasting it in there, what does that mean? I am completely new to using VBA. Sorry


Specifically, in the link above, I am getting a syntax error at the very very bottom with the line

hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)
 
The red text is simply code comments used to explain what the code is doing.
 
Getting There...

When I run it, I get a Compile Error, Syntax


Again, right above the red out comment at the bottom of the code, I get a yellow arrow pointing to

Public Function InputBoxDK(Prompt, Optional Title, Optional Default, Optional XPos, _
Optional YPos, Optional HelpFile, Optional Context) As String


Any suggestions....I GREATLY appreciate your help. Thanks again.
 
I cant open it, I am getting an unrecognized database format error which doesnt make sense. Maybe its because I am behind network or safeguards of some sort at work? Anything else or another way I can look at it? Sorry for the inconvenience.
 
I should mention I am using MS access 97. Gotta love my company...
 
Okay, I was able to open that one. I copied the module in that one exactly into the module in mine... Just to make sure, in access 97, I am supposed to copy that into a new module under the modules tab all the way to the right, correct? Then on my form on clicking the command buttons I have

Private Sub Command1_Click()
If InputBoxDK("Enter Password", "Quality Assurance") = "Accept" Then
Me!chkapproval = True
Me!chkapproval.Visible = True
Me!chkapproval.Locked = True
Else
Me!chkapproval = False
End If
End Sub


Private Sub Command4_Click()
If InputBoxDK("Enter Password", "Quality Assurance") = "Reject" Then
Me!chkreject = True
Me!chkreject.Visible = True
Me!chkreject.Locked = True
Else
Me!chkreject = False
End If


However, I am still getting a compile error wtih this line at code at the very bottom.

hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)

Its redded out still? I hope my analysis was clear, if you have questions I will try to answer them as best as possible.
 
When I check that line of code thats in red in the Immediate pane or window:

hHook = SetWindowsHookEx(WH_CBT, AddressOf NewProc, lngModHwnd, lngThreadID)

I get this error message: Compile error: Expected: Expression
 
The code may be calling a windows API from a newer version of windows and can't be run on 97. Then again you may be able to fix it by checking your references.
 
From a newer version of windows, or a newer version of Access. You think if I swtich to 03 or 07 for Access it might work?
 
Can somebody post a database that uses the DKInputBox code from above?
 
From a newer version of windows, or a newer version of Access. You think if I swtich to 03 or 07 for Access it might work?

It worked fine in 2003 on my machine.
 
Could you possibliy take a look at a stripped down version of mine. Im hopelessly lost. I will have to go find someone to zip it, my machine is a POS and keeps freezing. I hate networks
 
BTW, thank you again for all the help. cant thank you enough
 
If you don't mind me saying so, chasing this rabbit seems a bit overkill considering the functionality is built-in if you do your own password form - :)
 
Agreed. But I dont exactly know how to do that. I have about 20 forms and on each form I need someone to be be able to click on a command button for either yes or no, and then enter a password. I'm not sure hwo to do that. If no command button, I need two textboxes to be password protected. I'm just completely lost when it comes to doing these password things because they all seem to invove VB, which I'm unfamiliar with....lol as you can see, I'm kind of between a rock and a hard place.
 

Users who are viewing this thread

Back
Top Bottom