473,385 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Code to close on error

Private Sub Form_Current()
If Form.NewRecord = True Then
If DCount("Id", "Urenregistratie") = 4026 Then
MsgBox "Sorry, deze registratie gaat maar tot en met 31-12-2004",
vbOKOnly, "Toevoegen niet mogelijk"
DoCmd.Close
End If
End If
End Sub

It gives me an error on the command

DoCmd.Close.

How do I get the form to close if someone tries to add an account?

TIA

Henro

P.S. Do you have trouble too finding anything at all in the new helpfunction
in Access2003?
Nov 12 '05 #1
4 4840
Henro,
What error? Maybe the record can't be saved?
I think you don't want the record to be saved?
Hence I think you could use Me.undo before trying to close

--
Hope this helps
Arno R


"Henro V" <ma**********@hotmail.com> schreef in bericht news:bp**********@news4.tilbu1.nb.home.nl...
Private Sub Form_Current()
If Form.NewRecord = True Then
If DCount("Id", "Urenregistratie") = 4026 Then
MsgBox "Sorry, deze registratie gaat maar tot en met 31-12-2004",
vbOKOnly, "Toevoegen niet mogelijk"
DoCmd.Close
End If
End If
End Sub

It gives me an error on the command

DoCmd.Close.

How do I get the form to close if someone tries to add an account?

TIA

Henro

P.S. Do you have trouble too finding anything at all in the new helpfunction
in Access2003?

Nov 12 '05 #2
It gives: "Fout 2585 tijdens uitvoering: U kunt deze actie niet uitvoeren
terwijl een formulier- of rapportgebeurtenis wordt verwerkt."

That is the dutch version, I will try to translate:

"Error 2585 during event: U cannot perform this action while a form- or
report event is pending"

It doesn't matter where I put the code (on opening, close, after update,
before update), it generates the error as soon as the DoCMD.Close acform,
"MIS NONDEAL" is executed:

Private Sub Form_Current()
If Form.NewRecord = True Then
If DCount("Id", "Urenregistratie") = 4026 Then
MsgBox "Sorry, deze registratie gaat maar tot en met 31-12-2004 voor
Engineers. U probeert óf na deze dag toe te voegen óf u bent niet gerechtigd
informatie toe te voegen.", vbOKOnly, "Toevoegen niet mogelijk"
DoCmd.Close acForm, "MIS DEAL"
End If
End If
End Sub

If I delete the DoCmd.Close acForm, "MIS DEAL" it executes with no
errors but allows a record to be added to the table.
I want this form closed as soon as someone tries to open a record.

Any idea's, examples?

TIA Henro
"Arno R" <ar****************@tiscali.nl> wrote in message
news:3f**********************@dreader2.news.tiscal i.nl...
Henro,
What error? Maybe the record can't be saved?
I think you don't want the record to be saved?
Hence I think you could use Me.undo before trying to close

--
Hope this helps
Arno R


"Henro V" <ma**********@hotmail.com> schreef in bericht

news:bp**********@news4.tilbu1.nb.home.nl...
Private Sub Form_Current()
If Form.NewRecord = True Then
If DCount("Id", "Urenregistratie") = 4026 Then
MsgBox "Sorry, deze registratie gaat maar tot en met 31-12-2004", vbOKOnly, "Toevoegen niet mogelijk"
DoCmd.Close
End If
End If
End Sub

It gives me an error on the command

DoCmd.Close.

How do I get the form to close if someone tries to add an account?

TIA

Henro

P.S. Do you have trouble too finding anything at all in the new helpfunction in Access2003?


Nov 12 '05 #3
Henro,
Now I see what you'r trying to do ...
You need the event Before_Update if you want to prevent (updates or) new records
Like:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
.....
Cancel = True 'You NEED this
DoCmd.Close
End Sub

But: If you don't want to allow additions then you only need to set Me.AllowAdditions = False
You don't even need your code then.
Take a closer look at the properties of your form.
In Dutch: 'Toevoegingen toestaan: NEE'

--
Hope this helps
Arno R

"Henro V" <ma**********@hotmail.com> schreef in bericht news:bp**********@news2.tilbu1.nb.home.nl...
It gives: "Fout 2585 tijdens uitvoering: U kunt deze actie niet uitvoeren
terwijl een formulier- of rapportgebeurtenis wordt verwerkt."

That is the dutch version, I will try to translate:

"Error 2585 during event: U cannot perform this action while a form- or
report event is pending"

It doesn't matter where I put the code (on opening, close, after update,
before update), it generates the error as soon as the DoCMD.Close acform,
"MIS NONDEAL" is executed:

Private Sub Form_Current()
If Form.NewRecord = True Then
If DCount("Id", "Urenregistratie") = 4026 Then
MsgBox "Sorry, deze registratie gaat maar tot en met 31-12-2004 voor
Engineers. U probeert óf na deze dag toe te voegen óf u bent niet gerechtigd
informatie toe te voegen.", vbOKOnly, "Toevoegen niet mogelijk"
DoCmd.Close acForm, "MIS DEAL"
End If
End If
End Sub

If I delete the DoCmd.Close acForm, "MIS DEAL" it executes with no
errors but allows a record to be added to the table.
I want this form closed as soon as someone tries to open a record.

Any idea's, examples?

TIA Henro
"Arno R" <ar****************@tiscali.nl> wrote in message
news:3f**********************@dreader2.news.tiscal i.nl...
Henro,
What error? Maybe the record can't be saved?
I think you don't want the record to be saved?
Hence I think you could use Me.undo before trying to close

--
Hope this helps
Arno R


"Henro V" <ma**********@hotmail.com> schreef in bericht

news:bp**********@news4.tilbu1.nb.home.nl...
Private Sub Form_Current()
If Form.NewRecord = True Then
If DCount("Id", "Urenregistratie") = 4026 Then
MsgBox "Sorry, deze registratie gaat maar tot en met 31-12-2004", vbOKOnly, "Toevoegen niet mogelijk"
DoCmd.Close
End If
End If
End Sub

It gives me an error on the command

DoCmd.Close.

How do I get the form to close if someone tries to add an account?

TIA

Henro

P.S. Do you have trouble too finding anything at all in the new helpfunction in Access2003?



Nov 12 '05 #4
So simple I overlooked it! [blush] Thanx!
"Arno R" <ar****************@tiscali.nl> wrote in message
news:3f**********************@dreader2.news.tiscal i.nl...
Henro,
Now I see what you'r trying to do ...
You need the event Before_Update if you want to prevent (updates or) new records Like:
Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.NewRecord Then
....
Cancel = True 'You NEED this
DoCmd.Close
End Sub

But: If you don't want to allow additions then you only need to set Me.AllowAdditions = False You don't even need your code then.
Take a closer look at the properties of your form.
In Dutch: 'Toevoegingen toestaan: NEE'

--
Hope this helps
Arno R

"Henro V" <ma**********@hotmail.com> schreef in bericht

news:bp**********@news2.tilbu1.nb.home.nl...
It gives: "Fout 2585 tijdens uitvoering: U kunt deze actie niet uitvoeren terwijl een formulier- of rapportgebeurtenis wordt verwerkt."

That is the dutch version, I will try to translate:

"Error 2585 during event: U cannot perform this action while a form- or
report event is pending"

It doesn't matter where I put the code (on opening, close, after update,
before update), it generates the error as soon as the DoCMD.Close acform, "MIS NONDEAL" is executed:

Private Sub Form_Current()
If Form.NewRecord = True Then
If DCount("Id", "Urenregistratie") = 4026 Then
MsgBox "Sorry, deze registratie gaat maar tot en met 31-12-2004 voor Engineers. U probeert óf na deze dag toe te voegen óf u bent niet gerechtigd informatie toe te voegen.", vbOKOnly, "Toevoegen niet mogelijk"
DoCmd.Close acForm, "MIS DEAL"
End If
End If
End Sub

If I delete the DoCmd.Close acForm, "MIS DEAL" it executes with no
errors but allows a record to be added to the table.
I want this form closed as soon as someone tries to open a record.

Any idea's, examples?

TIA Henro
"Arno R" <ar****************@tiscali.nl> wrote in message
news:3f**********************@dreader2.news.tiscal i.nl...
Henro,
What error? Maybe the record can't be saved?
I think you don't want the record to be saved?
Hence I think you could use Me.undo before trying to close
--
Hope this helps
Arno R


"Henro V" <ma**********@hotmail.com> schreef in bericht

news:bp**********@news4.tilbu1.nb.home.nl...
> Private Sub Form_Current()
> If Form.NewRecord = True Then
> If DCount("Id", "Urenregistratie") = 4026 Then
> MsgBox "Sorry, deze registratie gaat maar tot en met

31-12-2004",
> vbOKOnly, "Toevoegen niet mogelijk"
> DoCmd.Close
> End If
> End If
> End Sub
>
> It gives me an error on the command
>
> DoCmd.Close.
>
> How do I get the form to close if someone tries to add an account?
>
> TIA
>
> Henro
>
> P.S. Do you have trouble too finding anything at all in the new

helpfunction
> in Access2003?
>
>



Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ht | last post by:
hi all, im kinda new to vb and i have code that unhides a hidden from on a key press for some reason though this code only works when running th app through by, ie. it wont work in the...
1
by: SABmore | last post by:
I have the following code that populates 3 independent drop-down boxes with data from arrays. From there the user can select a value from a drop-down list, or input data into a text box. The user...
1
by: John | last post by:
Hi First of all apologies for posting so much code but this is rather involved and I am totally stumped. Basically I have a main form (Staff Batch SMS/E-Mail) which calls a function (SendSMS) in...
6
by: cj | last post by:
Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class . It gives an example at the bottom that begins with:...
3
by: Greg Strong | last post by:
Hello All, Is there any way to close an ODBC connection via DSN without completely closing the Access front-end? I'm doing some testing with using Access as a front-end to Oracle 10g Express...
2
by: Bart Van der Donck | last post by:
Hello, I'm posting the software for one-FAQ-a-day as described on http://tinyurl.com/qcxw7 (comp.lang.javascript, July 18 2006, titled "CLJ newsgroup FAQ) and on http://tinyurl.com/ppt2s...
36
by: The Frog | last post by:
Hi Everyone, I am trying to find a solution for handling zipped data without the need to ship / install any DLL files with the database. Does anybody know of code to handle ZIP files that does...
9
by: MrDeej | last post by:
Hello guys! We have an SQL server which sometimes makes timeouts and connection errors. And we have an function witch writes and updates data in 2 tables on this server. When the SQL server error...
2
by: embz | last post by:
this post concerns three pages. 1. this page: http://www.katherine-designs.com/sendemail.php i get the following errors: a lot of it seems to deal with the PHP code i inserted to the page....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.