Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Access 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2003 VBA Programmer's Reference by Patricia Cardoza, Teresa Hennig, Graham Seach, Armen Stein; ISBN: 9780764559037
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 21st, 2004, 04:04 AM
Authorized User
 
Join Date: May 2004
Location: montpellier, 34000, France.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem with system message

in access while working with form;

in the field where the null value is not allow; I can catch the error message by handling the OnError of that form who give me the DataErr and Response As integer

by doing: response = true I can disappear the system message (the same message when I try to enter invalid data directly to the table) who comes after the sub OnError and who has the control’s name, who cause the problem;

but I can’t handle the name of that control, in order to set focus to that control and lead the user directly to enter this value.


Reply With Quote
  #2 (permalink)  
Old May 21st, 2004, 01:18 PM
Wrox Author
 
Join Date: May 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi! Thanks for posting. I need a little clarification on what you need. From what I understand from your post, you are getting an error message when a field that requires a value isn't filled in. So, what do you want to do? Do you want to then set the focus back to that control so that the user can enter the proper data?

Post back and let me know if that's what you're having problems with.

Thanks!

Patricia Cardoza
Outlook MVP

Lead Author, Access 2003 VBA Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old May 28th, 2004, 08:50 AM
Authorized User
 
Join Date: May 2004
Location: montpellier, 34000, France.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello Patricia Cardoza
firstly thank you for your enthusiastism then i would like to know that you are the one in the middle or on the left in the picture on the first page of the book?

then my problem is

i choose a field's data for text for example then i let it not allow null in .adp or require in .mdb then i catch the Sub OnError to handle this problem

Private sub OnError(DataErr As integer, Response As integer)
'i show my msg here
    msgbox my_msg
'i set this cmd to disappear the access msg
    Response = true

end sub

i want to get the control's ID whose cause the problem (error 3314 and 3315 this mean not allow null and not allow "") but i can't

i can only get the error discription by doing this

            msg = AccessError(DataErr)

then i can change the msg (to explain it in french language) but not the error.source who give the ID of the control who help me to set focus to this control after my msg

but access show a msg "the name [control ID] can not be null"
this means that access has this ID

then i have tried another solution

i set the default value to "" and this set the focus to that control after the access error msg in english but not my msg

so if you can get the Control's ID?
i am looking for your response and thank you very much

vubinhsg

Reply With Quote
  #4 (permalink)  
Old July 22nd, 2004, 08:49 AM
Authorized User
 
Join Date: Jul 2004
Location: Sydney, NSW, Australia.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

vubinhsg,

From your original post, I take it you're trying to figure out how to use the combo box's NotInList event.

See http://www.pacificdb.com.au/MVP/Code/NIL.htm for an explanation.

Regards,

Graham R Seach
Microsoft Access MVP
Reply With Quote
  #5 (permalink)  
Old July 25th, 2004, 07:51 PM
Authorized User
 
Join Date: Jun 2004
Location: Cumberland, MD, USA.
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Assume that you have a form (based on a table) which has two textboxes: txtState and txtZipCode which are bound to the fields State and ZipCode, respectively. Assume that both of these fields are REQUIRED. Add the following code to the OnError event of the form, which checks to see if the fields are NULL and then uses the setfocus method to put the cursor in that field:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 3314 Then
    If IsNull(txtState) Then txtState.SetFocus
    If IsNull(txtZipCode) Then txtZipCode.SetFocus
    Response = acDataErrContinue
    MsgBox "Required data missing"
End If
End Sub


Terry Waltz
Reply With Quote
  #6 (permalink)  
Old July 29th, 2004, 03:37 AM
Authorized User
 
Join Date: May 2004
Location: montpellier, 34000, France.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello tlwaltz,
i have done what you have suggested.
anyway, i think that i have to write a global SUB who catch the form's error message and give the form's name to my ErrorHandler, who goes detect all the coltrols of the form beacause we don't know when and what control will cause problems and my end-users read only vietnamse so it is very important to give the name of the controls.

that's what i think for so long and i think also that this job access has done and we have to repeat it again.

thanks for your help and see you another time.

vubinhsg

Reply With Quote
  #7 (permalink)  
Old July 30th, 2004, 01:20 AM
Authorized User
 
Join Date: Jul 2004
Location: Sydney, NSW, Australia.
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

With a slight change to tlwaltz's suggestion:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
    If DataErr = 3314 Then
        Screen.ActiveControl.Undo
        Response = acDataErrContinue
        MsgBox "Required data missing from " _
                & Screen.ActiveControl.Name
    End If
End Sub

Unless you catch it in the control's BeforeUpdate event, you won't be able to have it retain the focus.


Graham R Seach
Microsoft Access MVP
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
suppressing system message??? aspuser27 Excel VBA 2 June 5th, 2007 01:49 PM
supress system (sqlserver) message starnet SQL Server 2000 1 July 28th, 2006 04:34 AM
Problem with a system BigH140 Access 3 February 6th, 2006 04:57 PM
Error Message Problem kuku SQL Server 2000 1 September 6th, 2005 04:30 PM
Get message from system "print" dialog box pavel Pro VB 6 0 August 28th, 2003 09:31 AM



All times are GMT -4. The time now is 11:06 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.