Error on Switchboard with DoCmd!

G

Guest

I am trying to create a switchboard where when one button is clicked a form
opens in Add Mode, but then I need certain personnel to be able to click
another button and edit the form if needed (Edit mode). my problem comes in
that I want to add the following event procedure so that the form opens up to
a new form (quickest way to get to the last form entered). DoCmd.RunCommand
acCmdRecordsGoToNew. Once I do this however. The Add Mode of the first
button mentioned results in an error. Additionally is there a way I can set
a password on the edit button.
 
G

Guest

Hi

Why not have 2 forms ?. The 1st would open in Add - the 2nd in Edit you
will need a little bit code to make the whole thing work.

Private Sub txtpassword_AfterUpdate()
Static Counter As Integer
If txtPassword = 123 Then
DoCmd.OpenForm "Name of form in Edit", acNormal, "", "", , acNormal
DoCmd.Close acForm, "Switchboard name"
Else
If Counter < 2 Then
MsgBox "The password you entered is not correct - try again - MAX 3
ATTEMPTS?", vbOKOnly, "You can't open the form in edit - try again"
Counter = Counter + 1
txtPassword = ""
Else
DoCmd.Quit
End If
End If
End Sub


Of course anyone with a little knowledge about access would (if they wanted)
get round this. Not sure what your users are like.

To do this - on your switch board you should have only 1 button (to open the
form in Add) plus add an unbound text box (call it txtpassword - like
above).

As you will see the AfterUpdate above of the text box only gives the user 3
attempts at the password then it closes access -
you can change this by altering If Counter < 2 Then ..........

After the 1st 2 wrong attempts it gives the message - You can't open the
form in edit - try again. This line Static Counter As Integer enables the
counter.

Oh yes - I have set the password/number at 123 - I would change this if I
were you. If you are using text you should enclosed the "password" in
commas."xxx"

I would set the txtpassword text box to Input Mask = Password so you will
get *** instead of 123 and change "switchbopard name" in the code to what is
really is.

Hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top