Button code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to create a button that does one thing if a user enters the right thing and another if the user enters the wrong thing. It is probably and If Else thing but I don't know the right way to do it. Can someone help

Thanks.
 
Need example

RK

-----Original Message-----
I need to create a button that does one thing if a user
enters the right thing and another if the user enters the
wrong thing. It is probably and If Else thing but I
don't know the right way to do it. Can someone help ?
 
Katherine said:
I need to create a button that does one thing if a user enters the right
thing and another if the user enters the wrong thing. It is probably and If
Else thing but I don't know the right way to do it. Can someone help ?
In the on-click event something like.

If Me!EnterAName = "Mike" then
msgbox "You idiot I told you not to use that name."
Else
msgbox "good for you"
Endif

Note that a button is not needed here since it could be run from EnteraName.

You could also use something like

If Me!EnterAName = "Mike" then
Me!Yourbutton.visible = false
Else
Me!Yourbutton.visible = True
Endif
 
Well I'm trying to make a user name and password system that is probably already set up somewhere in Access but I have a table with user names and passwords and I want the users to enter the right name and password then click on a button which will open a form. If they don't put in the right password or leave the password field blank, I want a different form to pop up sayins that they have entered the wrong thing

----- RK wrote: ----

Need exampl

R

-----Original Message----
I need to create a button that does one thing if a user
enters the right thing and another if the user enters the
wrong thing. It is probably and If Else thing but I
don't know the right way to do it. Can someone help
 
Yes that's the kind of thing I'm looking for except that I need to compare the user's password and name to his/her record in the user table. So I'm comparing the name and password in a query and then I want the button to disappear or not accordingly. They pick their name from a list which is set so that's fine but then their password needs to match the one that is stored with there name in the a table.

I'll try have a fiddle tho

----- Mike Painter wrote: ----


Katherine said:
I need to create a button that does one thing if a user enters the righ
thing and another if the user enters the wrong thing. It is probably and I
Else thing but I don't know the right way to do it. Can someone helpIn the on-click event something like

If Me!EnterAName = "Mike" the
msgbox "You idiot I told you not to use that name.
Els
msgbox "good for you
Endi

Note that a button is not needed here since it could be run from EnteraName

You could also use something lik

If Me!EnterAName = "Mike" the
Me!Yourbutton.visible = fals
Els
Me!Yourbutton.visible = Tru
Endi
 
Um fraid I don't understand. It's a simple little database just for a few people but it is the start of a database that will eventually be used on a large scale so I want to get this right first.
What is DOA and multiuser


----- RK wrote: ----

two question

is this DO

is it a multiuser, ie Fe / B

RK
 
Multi user applications with Access are split between the Back End (BE) and the Front End (FE)
the BE has data only and the FE has evrything else, i.e. form reports, querys, etc
This is the prefered method. Then when your application is distributed you can take the FE.mdb an
convert it to an FE.mde so no one can alter the program

When you use DAO objects, you manipulate data almost entirely using Recordset objects

A new Recordset object is automatically added to the Recordsets collection when you open the Recordset object, and is automatically removed when you close it

This would be added by pressing ALT F11 key together to get to Visual Basic Editor in Access
Under refernces find Microsoft DAO 3.6 Object Library

Look at the built in help for DAO for futher details

It is important, because the choices that you make now will effect how the program can be used and what change
would have to be done later if you decide to split the database

R
 
I anticipate making it into a BE and FE :
Because I want the FE at a number of sites and the BE at the central server. I'm not really sure how this will effect my problem? What does a Recordset object have to do with creating a button that can do one thing or another depending on the information entered in a text box
Sorry if I sound dof, am still learning :

Thanks
 
Katherine said:
I anticipate making it into a BE and FE :)
Because I want the FE at a number of sites and the BE at the central
server. I'm not really sure how this will effect my problem? What does a
Recordset object have to do with creating a button that can do one thing or
another depending on the information entered in a text box.
Sorry if I sound dof, am still learning :)

Since you are still learning I would point out one thing before you put a
lot of effort into this.

A home-grown security system like you're proposing would be trivially easy
to circumvent by anyone who has even an introductory knowledge of Access.
Either utilize the built-in User-Level security that Access provides (not a
trivial thing to set up for the first time mind you) or don't bother with
it at all.

A couple examples:

If your users table is not secured anyone could link to it from another
Access file and read all of the user names and passwords out of it.

If you don't distribute as an MDE then anyone will be able to examine your
code to see how the password system is being enforced.
 
Private Sub Command_Click()
If Me.Password = "password" Then
'You could do a dlookup for users password like If
Me.Password=dlookup("[Password]","Password_Table", "[UserID] = " &
Me.UserID)
DoCmd.OpenForm "MenuMain"
Else
MsgBox "Incorrect Password"
DoCmd.Close
DoCmd.Quit
End If
End Sub

Katherine said:
I need to create a button that does one thing if a user enters the right
thing and another if the user enters the wrong thing. It is probably and If
Else thing but I don't know the right way to do it. Can someone help ?
 
Katherine said:
I just want to make sure that they login with their name...I guess I
don't even need a password, just some way to make the button olny
open the form if they have selected or typed in their user name.

If that's all you want to do, you could just grab their username, you could
use the function at
http://www.mvps.org/access/api/api0008.htm
to retrieve their network name.
 
RK said:
two questions

is this DOA
If it was she wouldn't need the information ;)

This one went right by me. I work in EMS and just could not "see" that DOA
was DAO.
 
Thanks everyone for your help. I have two options now...either I use the Access user setup or use code to compare the name and password...will have a think over which will be best considering this project and then try put either method into place.

Thanks again ..everyone has been very helpful ... I love this discussion thing :)
 
Um I'm trying your code but I'm not sure what I should put as criteria...I have a table called tUsers with the fields: User Code and Password. The user selects his/her name in a Combo14 and types the password in Text6. I want to make sure the User Code and Password match a record in tUsers. If it does match, the form fUserSchedule must open but if it doesn't match, an error message must pop up and then they can try re-enter the correct password

I tried this but I know my criteria in the dlookup is/are wrong...some help getting the code right

Private Sub bOpnfUserSchedule_Click(
If Text6 = DLookup("[Password]", "tUsers", "[tUsers]=" & Combo14) The
DoCmd.OpenForm "fUserSchedule
Els
MsgBox "Incorrect Password
DoCmd.Clos
DoCmd.Qui
End I
End Su

Thanks :)
 
Okay it works if I take out the criteria but then it only works for the first record in the table....how can I set up the criteria so that it looks through all the records in tUsers?
 
Hooray...I fixed it! I now know how to set criteria :) It all works hunky dory and I'm needless to say very excited cos now I can move onto the next problem I don't know how to do...but won't worry bout that for now...am going to revel for a few minutes in the fact that I have got something working :

With everyone's help or course ;

Thanks everyone :)
 
Gotta to love the typos . .

R

----- Mike Painter wrote: ----


RK said:
two question

If it was she wouldn't need the information ;

This one went right by me. I work in EMS and just could not "see" that DO
was DAO
 
Back
Top