Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems with an addrec form

Status
Not open for further replies.

jordanh

Technical User
Nov 11, 2002
47
GB
Hi everyone, hope you can help me here.

I have a form which I use to add records with two buttons used to exit, 'add' and 'cancel'. I have two problems.

1) If I click cancel, you get the 'is it OK to delete record?' Yes/No box. Clicking Yes is fine but if the user clicks No I get "run-time error 2501 The DoMenuItem action was cancelled". Does anyone know a simple way to stop this dialog box from appearing?

2) This one is more important (so why didn't I mention it first?!). I need the form to appear without the max min and close buttons, i.e. as a popup. The only problem is that if I set it to be a pop-up window I get an error when trying to cancel. It's the same error as above (DoMenuItem action as cancelled). This is the code I use on the cancel button:

Private Sub cancel_Click()
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Forms![add_nav].SetFocus
Forms![add_nav]!SysList.Requery
Forms![add_nav]!SubList.Requery
Forms![add_nav]!PlantList.Requery
DoCmd.Close acForm, "add_item"
End Sub

Can anyone think why this is causing an error *only* if used on a popup form.

Thanks for your time everyone,

Jordan
 
Hi

To get rid of the 2501 cancel 'error' mesage, use ON ERROR to set an error trap and disregard the error 2501 in the on click event of your cancel button

Eg Something Like

ON Error GoTo Error_Trap

...blah blah

Exit_Click:
Exit Sub
Error_Trap:
If err.Number = 2501 then
resume next
Else
..blah..
End If

To get rid on the max/min/ close etc set the following Form Properties:

.ControlBox = False
.MaxMinButtons = None
.CloseButton = False
Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
thanks a lot, the solution to get rid of the error message worked a treat, I didn't know you could if err.number = #. Useful!

However, the other point is still a problem.

I have got controlbox, max/min and close buttons turned off but they still appear. The ideal screen I want is the popup style, where the form overlays everything (including access) and is maximised (I am also using DoCmd.Maximise onOpen).

Basically I want to force the user to use my buttons and not be able to navigate 'normally'. I have another (nearly identical) form which does exactly this, popup - no buttons. Both forms can save and exit fine, it's only when it comes to cancelling and thus deleting a record that there's a problem.

Thanks for everything so far though! I you have any more ideas I'm anxious to hear them!

Jordan
 
The problem with that method is that I lose all the data that is passed to the form, I can't save it or cancel.

Is this because the 'form' is no longer a form but a dialog? so Forms!add_item!System = "blah blah" no longer does anthing as add_item is no longer a form but a dialog?

This screen is an editing screen so I need to be able to change the record.

Can you think of a reason that access won't let me exit a pop-up form in the same way I exit the exact same form but with pop-up = false.

Thanks for all your help, it's appreciated.

Jordan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top