473,418 Members | 2,091 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,418 software developers and data experts.

Clear Error Message from TextBox

Ok I got it now, thank you everyone for that. Now I have another question. I'm creating an error report from, if a textbox is blank then it'll display a text in another textbox stating "Textbox is blank, please enter a value" etc... So it will look something like this....
Expand|Select|Wrap|Line Numbers
  1. Private Sub FormCheckButton_Click()
  2. If TextboxA = "" Then
  3. ErrorBox = "TextBoxA cannot be blank, please enter value"
  4. End If
Now when TextBoxA is answered, and when the FormCheckButton is clicked for another form review, how do I remove the "TextBoxA cannot be blank, please enter value" message from the ErrorBox? Hopefully all this made sense.

** Edit **
This question was asked in another thread (What is the VB code for looking up a value in a table?). Please post new questions in their own threads in future.
Jul 25 '10 #1
11 2578
mseo
181 100+
@Jonathan Austin
you can use something like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Check1_Click()
  2. If Me.check1 = -1 Then
  3. Me.errorbox= ""
  4. DoCmd.OpenForm "your form name"
  5. Me.check1 = 0
  6. End If
  7. End Sub
  8.  
hope this helps
Jul 25 '10 #2
Unfortunately that won't, because my error box will be compiled with other text, so I just want to eliminate certain text. I'll write it out for better understanding.
Expand|Select|Wrap|Line Numbers
  1. Private Sub ReviewButton_Click()
  2. If ComboBoxA = "" Then
  3. ErrorBoxA.Text = "ComboBoxA Cannot Be Blank, Answer Is Required"
  4. End If
  5.  
  6. If ComboBoxB = "" Then
  7. ErrorBoxA.Text = ErrorBoxA.Text & "ComboBoxB Cannot Be Blank, Answer Is Required"
  8. End If
  9.  
  10. If ComboBoxC = "" Then
  11. ErrorBoxA.Text = ErrorBoxA.Text & "ComboBoxC Cannot Be Blank, Answer Is Required"
  12. End If
  13.  
  14. End Sub
ErrorBoxA should read,
ErrorBoxA: ComboBoxA Cannot Be Blank, Answer Is Required
ComboBoxB Cannot Be Blank, Answer Is Required
ComboBoxC Cannot Be Blank, Answer Is Required

I want to know, if ComboBoxB IS NOT blank, what would be the code to remove the "ComboBoxB Cannot Be Blank, Answer Is Required" text from ErrorBoxA while leaving the rest?
Jul 25 '10 #3
mseo
181 100+
so, you want to prevent any of the comboboxes from being null or blank , and want to view the messages in textbox istead of msgbox, is that right?
Jul 25 '10 #4
Yes thats correct, after my personnel enter information, (its alot of information to be enter, so there will be entries that may be over looked.) So any blank entries I want the errors to show up as text in the error boxes (error boxes = textboxes) not msgbox.
Jul 25 '10 #5
@Jonathan Austin
- I could have all the fields required, but it would be annoying to hear 'dings' after each one, which by the way, all entries are required.
Jul 25 '10 #6
mseo
181 100+
@Jonathan Austin
So, It would be like this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If IsNull(Me!Text1) Then
  3. Me.Text2 = "text 1 is blank, it is required"
  4. Cancel = True: Me.Text1.SetFocus
  5. ElseIf Not IsNull(Me.Text1) Then
  6. Me.Text2 = ""
  7. End If
  8. If IsNull(Me!T5) Then
  9. Me.T6 = "text 5 is blank, it is required"
  10.  Cancel = True: Me.T5.SetFocus
  11. ElseIf Not IsNull(Me.T5) Then
  12. Me.T6 = ""
  13. End If
  14. End Sub
  15.  
in the demo, generate an ID and try to move to the next record
hope this helps
Attached Files
File Type: zip demo.zip (41.6 KB, 102 views)
Jul 25 '10 #7
Actually I figured out what I needed, I'll post it, it may help others on this. Its basically like creating your own verison of an error report.

Check this out
Attached Files
File Type: zip Demo.zip (36.7 KB, 99 views)
Jul 25 '10 #8
NeoPa
32,556 Expert Mod 16PB
Jonathan Austin: Ok I got it now, thank you everyone for that. Now I have another question. I'm creating an error report from, if a textbox is blank then it'll display a text in another textbox stating "Textbox is blank, please enter a value" etc... So it will look something like this....
Expand|Select|Wrap|Line Numbers
  1. Private Sub FormCheckButton_Click()
  2. If TextboxA = "" Then
  3. ErrorBox = "TextBoxA cannot be blank, please enter value"
  4. End If
Now when TextBoxA is answered, and when the FormCheckButton is clicked for another form review, how do I remove the "TextBoxA cannot be blank, please enter value" message from the ErrorBox? Hopefully all this made sense.
The simple answer to this is :
Expand|Select|Wrap|Line Numbers
  1. Private Sub FormCheckButton_Click()
  2.     ErrorBox = IIf(IsNull(Me.TextBoxA), _
  3.                    "TextBoxA cannot be blank, please enter value", _
  4.                    Null)
  5. End If
I'd suggest rather that this code be put in TextBoxA_AfterUpdate() though, unless you have a good reason for wanting to make the operator work to get the response.
Jul 25 '10 #9
NeoPa
32,556 Expert Mod 16PB
Jonathan Austin: Actually I figured out what I needed, I'll post it, it may help others on this.
As a general rule yes. On the other hand posting an attachment as a solution on a forum like this is pretty much a waste of time.

If people are scanning through web pages to see if they've found something that can help them they want to be able to see it without downloading, opening, navigating to the relevant part, etc before they see what they're after.

Attachments are for things a little more complicated than simple concepts easily shown in a few lines of code.

Please feel free to post your solution if you think it will help. We are always pleased to see such responses. Particularly from those that ask the question in the first place, as it indicates they've learned something from visiting Bytes, which is fundamentally what we are aiming for.
Jul 25 '10 #10
NeoPa
32,556 Expert Mod 16PB
As the question has changed from the original one (to include the idea that multiple error messages are included in the TextBox) I will suggest a more appropriate alternative. At least I will outline the concept for now. The previous code indicates some of what is required as building blocks.

Firstly, each control that has the potential for producing an error message in [TextBoxA] would need an AfterUpdate event procedure which calls a separate procedure, we'll call this UpdateError(), that works out what the contents of that control should be. There would be code within UpdateError() to handle each of the said controls. For each control there would be code, similar to that found in post #9, to set or clear the part related to that control depending on the current contents of the control.

Separating each message from the next would be done by including the inbuilt value vbNewLine. Only required for controls that actually trigger error messages of course.
Jul 25 '10 #11
mseo
181 100+
@NeoPa
that's true Neopa, We have learned a lot of things from here
thank you
Jul 26 '10 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
3
by: Ricardo Corsi P. Cesar | last post by:
I have many textbox in my webform, but i want clear all of them with on single step. Someone have the code ? Thks
1
by: Jeremy Ames | last post by:
I have a datagrid that updates the table using a stored procedure. The stored procedure is confirmed to complete correctly, yet the sql data adapter is returning an error that my application is...
2
by: Eric | last post by:
When i try to run that method in my continuous form it gives error message: invalid operation Here txt is the textbox which bind with the table tbl_Events Private Sub Form_Load() Dim qry As...
1
by: bruce24444 | last post by:
I am designing a database to use a work to assign files to certain people. Form includes Date textbox, File Number textbox, File Type combobox and Assigned To combobox. The form is working fine and...
3
by: dancer | last post by:
I am using Framework 1.1.4322. Who can tell me why I'm getting this error? My code follows Compilation Error Description: An error occurred during the compilation of a resource required to...
1
by: Claudia Fong | last post by:
In my windows form I have a comboBox and a textBox. When I try to write something in the textBox it shows me the error message below: Attempting managed execution inside OS Loader lock. Do not...
2
by: pvong | last post by:
VB.NET / ASP.NET I have a simple test. One simple Formview connected to a datasource. I have Button1 outside of the Formview. The Formview starts in ReadOnlyMode. All I want to do is on the...
2
by: dnnddane | last post by:
Hi All, I try to create a sample asp.net ajax application in visual studio 2005. I have 1 textbox, 1 requirefieldvalidator and 1 button. All are in updatepanel. When I click the button and the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.