 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 21st, 2004, 04:04 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 21st, 2004, 01:18 PM
|
|
Wrox Author
|
|
Join Date: May 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

May 28th, 2004, 08:50 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

July 22nd, 2004, 08:49 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

July 25th, 2004, 07:51 PM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

July 29th, 2004, 03:37 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

July 30th, 2004, 01:20 AM
|
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |