Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / September 2007

Tip: Looking for answers? Try searching our database.

Select Case

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jean.ulrich@snclavalin.com - 17 Sep 2007 09:34 GMT
Hi

I have a text box on a form so user can write a password

I also have a button

here what I want

If the user put "123" and click the button, form "Employees" open
if the user put "abc" and click the button, form "Customers" open
if the user put "xxx" anc click the button, form "Products" open

I know I should use the select case method, but I don't know how to do
it, how to create the code, how to start

Should I create a statement and then on the "click" event of the
button put someting like "call the statement" or put the code on the
click event of the button !!!!!

thanks for your help
Wayne-I-M - 17 Sep 2007 10:28 GMT
Private Sub TextBoxName_Click()
Static Counter As Integer
If txtPassword = "123" Then
   DoCmd.OpenForm "Employees", acNormal, "", "", , acNormal
Else
If txtPassword = "ABC" Then
   DoCmd.OpenForm "Customers", acNormal, "", "", , acNormal
Else
If txtPassword = "XXX" Then
   DoCmd.OpenForm "Products", acNormal, "", "", , acNormal
Else
   If Counter < 2 Then
       MsgBox "The password you entered is not correct - try again - MAX 3
ATTEMPTS?", vbOKOnly, "Database entry declined"
       Counter = Counter + 1
       txtPassword = ""
   Else
       DoCmd.Quit
   End If
   End If
End If
End Sub

Change textBoxName to what it really is

You can delete this bit if you want (but I would leave it on)
   If Counter < 2 Then
       MsgBox "The password you entered is not correct - try again - MAX 3
ATTEMPTS?", vbOKOnly, "Database entry declined"
       Counter = Counter + 1
       txtPassword = ""

Hope this helps

Signature

Wayne
Manchester, England.

> Hi
>
[quoted text clipped - 16 lines]
>
> thanks for your help
Pieter Wijnen - 17 Sep 2007 16:08 GMT
"Prettier" is

Select Case Me.txtPassword.Value
Case "123"
   DoCmd.OpenForm "Employees", acNormal
Case "ABC"
   DoCmd.OpenForm "Customers"", acNormal
Case Else
 MsgBox "Invalid Password"
End Select

HTH

Pieter

> Private Sub TextBoxName_Click()
> Static Counter As Integer
[quoted text clipped - 50 lines]
>>
>> thanks for your help
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.