Is it possible to stop this message from appearing?
I've got a couple of unbound textboxes that I want to use as filters for start date/end date type parameters. I wanted to use the build-in calendar option to let users select a date (as well as being able to type it in) so I set the format of the text boxes to Short Date. However in doing this it means that this "invalid value" message now pops up when the date format is wrong, as opposed to the LostFocus event I had to check the date format and alert the user.
Any idea if it's possible to hide/disable these kinds of messages? Would it be in a similar way to DoCmd.SetWarnings False/True?
Thanks.
Adam.
18 15284 NeoPa 32,556
Expert Mod 16PB
You could check out Custom Error Messages, but I don't think this is your best approach. As what you require is a little unusual you can expect to use a fiddly solution. Mine would be to clear any format of the TextBox control on Entry (the event), and determine it again After Update (event) by the value entered. That way you wouldn't be constrained by the Format while entering data.
Jeez Neo, you're quick on the draw :)
Adam if you want to go the "Custom Error Message" way then catch the error number and display a custom message in relation to that number -
Private Sub somefunction()
-
On Error GoTo errorCatching
-
-
'...some code
-
-
errorCatching:
-
msgbox Err.Number
-
' you will have to determine what number
-
' comes up as you enter some wrong data
-
' for testing purposes
-
-
If Err.Number = 2421 Then
-
MsgBox ("please enter an appropriate date")
-
End If
-
End Sub
-
-
-
Mmm yeah I don't think that approach would work - that seems to be based around using the run time error codes, whereas this doesn't have one.
The reason I used format was because it seems to be the cleanest way to get a calendar for the text boxes, unless there's another way? (aside from building a calendar form)
best for me is to force users to select a date from the control, no more formatting problem
pod
have you tried catching the error number and then displaying a custom message in relation to that number
All my procedures already use error trapping. However this is not an 'error' in the sense that the coding is triggering a run time problem with a code. It's caused by the data inputted, not the design, and shows just a standard messagebox with an OK button, just informing the user that the value isn't valid.
Mmm the control-only idea could work, but how could I restrict access and still have the calendar functional? Locking the textbox stops user from editing it themselves, but it also stops the calendar from updating the value. And obviously setting the Enabled value to no will stop the users from entering the field at all, which means the calendar won't appear.
no need to lock ...you could set the onClick textbox event to show the calendar and set the focus to it. Then after the user clicks a date, you set that value to the textbox
...with a bit more code to make it work
I hope this helps -
Private Sub Calendar2_Click()
-
Text0.Value = Calendar2.Value
-
Text0.SetFocus
-
Calendar2.Visible = False
-
End Sub
-
-
Private Sub Text0_Click()
-
Calendar2.Visible = True
-
Calendar2.SetFocus
-
End Sub
NeoPa 32,556
Expert Mod 16PB OnClick assumes the operator will always use the mouse. Try OnEnter instead for more reliably working code.
PS. Was the (main) idea (Event procedures to clear the Format property when entering data into the control) in post #2 missed? I don't see any response to it and was wondering why it might not be appropriate.
NeoPa 32,556
Expert Mod 16PB Adam Tippelt:
However this is not an 'error' in the sense that the coding is triggering a run time problem with a code. It's caused by the data input
Although I still think this approach limited and am not recommending it, I do believe that ADezii's article on error message substitution may well work in this scenario too (as well as for the more usual code error messages).
Although I still think this approach limited and am not recommending it, I do believe that ADezii's article on error message substitution may well work in this scenario too (as well as for the more usual code error messages).
Doesn't ADezii's article work on the basis that the error has a run time code that you use to distinguish what should be done for each error? As the 'error' I have doesn't have a code, surely this wouldn't work? (Unless it has a code but doesn't display it?)
PS. Was the (main) idea (Event procedures to clear the Format property when entering data into the control) in post #2 missed?
Yes...yes it was. :)
I think I completely misread that post - I thought you were talking about removing the Format option completely, but you're talking about temporarily.
Huh...that might be suitable...I'll investigate that and say if it works. :)
Thanks.
Adam.
@Pod can you actually reference the ActiveX Calendar in the way you're suggesting? I can understand that working from a form-build calendar, but I was hoping to avoid adding one of them in.
Why not use IsDate() function to verify if the value in your text box is a valid date ?
I am Mihail - that's exactly what my own code uses. But the problem is that the system has it's own built in error/messagebox for textboxes formatted for dates. I'm trying to stop this firing so that it'll display my own message instead.
Mine would be to clear any format of the TextBox control on Entry (the event), and determine it again After Update (event) by the value entered. That way you wouldn't be constrained by the Format while entering data.
Unfortunately your suggestion does not quite work NeoPa. The calendar icon only appears when you enter the textbox (and subsequently disappears when you exit the textbox), so to disable the textbox's format On Entry would be to remove that functionality completely.
I tried applying a similar sort of strategy to things like the Keydown event, and while this works the problem with that strategy is the calendar icon doesn't seem to disappear, so you're left with an unusuable and misleading calendar icon, and I can't seem to get it to disappear...
So Adam, do not format the text box. Make a label where you show the good format to enter (i.e yyyy:mm:zz). Then check using code if the user enter data as you teach him in the label. It is just an idea. More: I think that NeoPa's suggestion to use a Calendar control is the best. What about to replace your text box with the Calendar control ?
Good luck !
Ah. I've just realised that I think I've been thinking of something else when you've all been saying Calendar control...I always forget about ActiveX controls...
Yes maybe that would be a suitable replacement. I'll see how that works.
Cheers.
Adam.
I am attaching a simple version of what I was suggesting. I added the onEnter event as well as Neo suggested.
You may want to play with the events to simulate the action as you see fit...
I hope it helps
Ah just spotted your example - that's pretty much what I'd ended up doing. Seems to work well enough.
Thanks.
Adam.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jrefactors |
last post by:
I have an upload file operation in the web application. UploadForm.jsp
is the form,
and UploadAction.jsp is the form processing. The web server is
Websphere.
//UploadForm.jsp
<FORM...
|
by: lottaviano |
last post by:
I am using Access 2002 and have two tables (Main and Actions) linked
(in Relationships) on one field "CAL_ID" (primary key in Main Table).
Main Table is a list of equipment. Actions Table lists...
|
by: Horst Walter |
last post by:
What is wrong here?
IPAddress ipAddress = IPAddress.Parse("10.10.20.1");
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, this.port);
this.tcpClient = new TcpClient(ipEndPoint); // PROBLEM HERE...
|
by: Jack MacRank |
last post by:
Hello,
I'm coding a webform application in C# (ASP.NET 1.1 SP1 with VS.NET 2003 Pro
on WinXP SP2 using IIS 5.1).
I created a seperate "data" class to house all the MySQL connection and sql...
|
by: Pieter |
last post by:
Hi,
I'm having some weird problem using the BackGroundWorker in an Outlook
(2003) Add-In, with VB.NET 2005:
I'm using the BackGroundWorker to get the info of some mailitems, and after
each item...
|
by: Mr Flibble |
last post by:
Hi All
I've decided to put my stylesheets in a base64 .resource file for
deployment and versioning reasons. I dont know if it's a great idea to
do this but I couldn't think of another way of...
|
by: keithb |
last post by:
Using a GridView, I get a "Specified cast is not valid" error when binding
the Visible propery of a hyperlink control to a DataTable text field. The
error goes away if I replace the data binding...
|
by: keikoo |
last post by:
Hi, I need some help with this control.
There's a windows form with a axwebbrowser control inside, so users can
navigate to a page and it's necessary to keep the session, because,
users will...
|
by: Ecohouse |
last post by:
I have a main form with two subforms. The first subform has the child
link to the main form identity key.
subform1 - Master Field: SK
Child Field: TrainingMasterSK
The second subform has a...
|
by: Emily Lisker |
last post by:
I am using Yes/No/Null number combo boxes per Allen Browne's instructions (http://allenbrowne.com/NoYesNo.html). My validation rule is:
"Is Null Or 0 Or -1"
I copied Allen Browne's lookup box...
|
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
|
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...
|
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...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
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...
| |