Access 2007 Password Form

Switchboard area should open

Page 1 of 1

3 Replies - 6658 Views - Last Post: 23 March 2009 - 01:21 PM

#1 mysticmayhem  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 15-February 09

Access 2007 Password Form

Posted 22 March 2009 - 01:16 PM

I have a switchboard in an access 2007 database that has one area that clients can access and an area where only the admin can enter. I have a password form and have written code to open the area of the switchboard that is for admins only, but when I enter the correct password it doesn't open anything. Can someone please look at my form and let me know whats wrong. I went to the switchboard items table to make sure that the Item Number and Switchboard ID were correct and they are. Here is my code:


Private Sub Command1_Click()

   On Error GoTo ErrorPoint

If Len(Nz(Me!PassTextBox, "")) = 0 Then
	MsgBox "Please enter a password before continuing." _
	, vbCritical, "Missing Password"
	Me.PassTextBox.SetFocus
Else
	If Me.PassTextBox <> "password" Then
		' Substitute with your own password between the quotes
		MsgBox "Incorrect Password", vbExclamation, "Access Denied"
		Me.PassTextBox = ""
		Me.PassTextBox.SetFocus
	Else
		Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 2"
		Forms!Switchboard.Refresh
		DoCmd.Close acForm, "PasswordForm"
	End If
End If

ExitPoint:
	Exit Sub

ErrorPoint:
   ' Unexpected Error
   MsgBox "The following error has occurred:" _
   & vbNewLine & "Error Number: " & Err.Number _
   & vbNewLine & "Error Description: " & Err.Description _
   , vbExclamation, "Unexpected Error"
   Resume ExitPoint

End Sub



Thank you for any help!

Is This A Good Question/Topic? 0
  • +

Replies To: Access 2007 Password Form

#2 Raju2047  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 55
  • Joined: 16-February 09

Re: Access 2007 Password Form

Posted 22 March 2009 - 04:50 PM

i didn't see the code to open your switchboard form.
docmd.openform "switchboard"


And one thing. the password is case sensitive. Haven't you query teh password from recordset.
Was This Post Helpful? 0
  • +
  • -

#3 mysticmayhem  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 15-February 09

Re: Access 2007 Password Form

Posted 22 March 2009 - 05:43 PM

Where would I put that, I thought the same thing, but wasn't sure where to put it within the if statement where the filter is. Would I put it before the Forms!Switchboard.Filter or after or what? Lol. Ok, I tried it like both of these below, but it still doesn't work.

	Else
								DoCmd.OpenForm, "Switchboard"
		Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 2"
		Forms!Switchboard.Refresh
		DoCmd.Close acForm, "PasswordForm"
	End If




	Else
		Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 2"
								DoCmd.OpenForm, "Switchboard"
		Forms!Switchboard.Refresh
		DoCmd.Close acForm, "PasswordForm"
	End If




	Else
		Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 2"
		Forms!Switchboard.Refresh
								DoCmd.OpenForm, "Switchboard"
		DoCmd.Close acForm, "PasswordForm"
	End If



I even tried it without the Refresh statement. But I am not trying to open the main switchboard, I want to open one of the other ones under the main switchboard.

This post has been edited by mysticmayhem: 22 March 2009 - 05:55 PM

Was This Post Helpful? 0
  • +
  • -

#4 mysticmayhem  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 29
  • Joined: 15-February 09

Re: Access 2007 Password Form

Posted 23 March 2009 - 01:21 PM

I still need help with this, please can someone help me. The password form works, but the switchboard area I want it to allow access to isn't opening, thank you. Cari
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1