Enable Button with Validation Rule

TerribadCoder

Registered User.
Local time
Yesterday, 18:20
Joined
Mar 8, 2014
Messages
20
[SOLVED] Enable Button with Validation Rule

Hi All,
Got another for you elite coders... tell me if you think I'm going about this the wrong way or if I'm making this WAY too complicated.

I have a button on a form that when I press it, I want it to validate a user's Windows Login ID in a text box on the current form against a table before allowing them access to a form.

If the Login ID in the text box does not match any value in the table I have defined, I wanted a MsgBox displayed saying invalid credentials. Of course if the ID exists in the table, I'd like it to open the next form.

Any ideas? Thanks!
 
Last edited:
Perfectly achievable.

The code to identify the ID of the current user is widely available. Once you have that in place, you just need to do a Dcount() of that UserID in your valid ID's table. If the Dcount() >0 then its valid, otherwise it's not.
 
That's what buttons are good at. With what function are you having a problem?
 
Perfectly achievable.

The code to identify the ID of the current user is widely available. Once you have that in place, you just need to do a Dcount() of that UserID in your valid ID's table. If the Dcount() >0 then its valid, otherwise it's not.

I'm having trouble getting this to work properly. I'm failry new to access and I'm sure don't have all the concepts down.

The table name is Employee, and ID being the field I'm trying to compare LoginID (a textbox on the form that is pulling the ID) with.

I've attempted using the Dcount() but keep running into error after error. Any help is appreciated!
 
Ok, I jumped the gun a little bit! Turns out I was missing a ' the whole time after the field was identified in the criteria. This works perfectly when the syntax is correct!

If DCount("[ID]", "Employee", "[ID]='" & Me.Text33 & "'") > 0 Then

Thanks!
 

Users who are viewing this thread

Back
Top Bottom