A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Form_open Cancel question



 
 
Thread Tools Display Modes
  #1  
Old March 21st, 2006, 02:38 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Form_open Cancel question

Hi,

i've got a form where i'm calling another form with Docmd.Openform

now in the form i'm calling, in the form_open, i'm testing a few conditions.
Only if the conditions are met the form should open. so when the conditions
aren't met i say

Cancel = True

But then in the calling form i get an error, saying that opening the other
form was cancelled. Which is logical, since i cancelled it. However, i don't
want that error, i just want te form not to open if those conditions aren't
met.

Any ideas on this?

Thx in advance!

Thomas L.


  #2  
Old March 21st, 2006, 02:49 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Form_open Cancel question

Add error-handling to the procedure that contains the OpenForm.
Trap and ignore error 2501.

Example:

Private Sub OpenMyFOrm_Click()
On Error GoTo Err_Handler

DoCmdOpenForm "Form2"

Exit_Hander:
Exit Sub

Err_Handler:
If Err.Number 2501 Then
MsgBox "Error " & Err.Number & ": " & Err.Description
End If
End Sub

More on error handling:
http://allenbrowne.com/ser-23a.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Mr. T." wrote in message
...
Hi,

i've got a form where i'm calling another form with Docmd.Openform

now in the form i'm calling, in the form_open, i'm testing a few
conditions. Only if the conditions are met the form should open. so when
the conditions aren't met i say

Cancel = True

But then in the calling form i get an error, saying that opening the other
form was cancelled. Which is logical, since i cancelled it. However, i
don't want that error, i just want te form not to open if those conditions
aren't met.

Any ideas on this?

Thx in advance!

Thomas L.



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exam question wrong about Word? Opinions, please! Jamie Furlong New Users 6 April 18th, 2006 11:56 AM
Cancel still adds record Tee See New Users 22 February 8th, 2006 11:40 PM
Search my question lost in the long list Shrikant General Discussion 3 August 26th, 2005 09:32 AM
MVP Question (database Design & Server Requirements) rayrock Database Design 3 August 12th, 2005 02:45 AM
database design question e-mid Database Design 9 June 16th, 2004 09:42 PM


All times are GMT +1. The time now is 09:40 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.