Hi all.
I have a couple of dtpicker controls on a form. When one is changed by the user (that's me, in this case) the code in the _Change event sets the other one, to keep it within a logical range (can't start a task before it's requested).
I know I had this working, but don't recall for certain what has changed. Anyway, it is now causing - Run-time error '2763':
-
-
DTPicker returned the error: An error occurred in a call to the Windows
-
Date and Time Picker control..
I've been doing some searching on TSDN and elsewhere, without success so far.
Oh, just had a thought. Is it possible I'm just running into the old silliness of not being able to address the properties while the control is hidden? I'll test that and get back to you.
26 13197
Damn! That was it.
I still can't believe Access VBA is so stupid it can't change a property of a hidden control. :( Now I'll have to rewrite all my code to show the control, change it, then re-hide it - but only if it was hidden to start with. Grrr...
nico5038 3,080
Recognized Expert Specialist
You can keep the control visible, but use a rectangle on top and manage the visibility of that to reveal the dtpickers.
Nic;o)
You can keep the control visible, but use a rectangle on top and manage the visibility of that to reveal the dtpickers.
Sneaky - I like it! :)
Sneaky - I like it! :)
Argh!
How can I cover up the dtpicker? I've tried placing a label and an option group over it. They can both cover up the label, but the actual picker control shows through them. (Yes, I have them set to "normal", not transparent).
I can't seem to create a unbound object frame without placing an object in it, or an image control within putting an image in it. I keep trying things that are perfectly simple in VB6, and running into limitations in Access. :(
I suppose if necessary I can create a small image using the same colour as my background, but what if the colour scheme changes? And will the image control work as a cover? I'll have to test it - hopefully some time today.
Any other ideas for a "lid" control I can put over my dtpickers? I love the idea, but so far the implementation is proving to be a real pain.
P.S. The various controls that I tried did cover up the dtpicker at design time, but at runtime, no-go.
nico5038 3,080
Recognized Expert Specialist
And hiding the form, then set the dtpickers and then show the form ?
Nic;o)
And hiding the form, then set the dtpickers and then show the form ?
Interesting idea, but not likely to be an option in this case. Each click to a datepicker adjusts others to keep them in synch.
This is starting to feel just like MS Word - you know, the way it seems to be designed to prevent you finding any way to do what you want to do. No matter which way you turn, they've found some way to cut off that approach. :(
In this case, I think I'm going to go back to my original technique, hiding and showing the dtpickers. But rather than setting their Value directly, I'll pass the control and the new value to a routine which performs this logic - Hold the value of .Visible property
-
If it's hidden Then
-
Set .Visible to True
-
End If
-
Set .Value to passed value
-
If it was originally hidden Then
-
Set .Visible = False
-
End If
Seems a bit of an ugly solution, but I think it should work. I'm thinking of also passing the property name, so I can use it for things other than .Value.
...I'm thinking of also passing the property name, so I can use it for things other than .Value.
Well, what a surprise! It didn't work.
I expect it will work alright if I use the original routine to explicitly set the .Value property, but when I passed the string "Value" and tried to set control.Properties(PropName) I got run-time error '2455': You entered an expression that has an invalid reference to the property Value.
Sigh... :(
I've changed my code to invoke a new sub which works as outlined above. It's not elegant, but appears to work.
Since hiding the dtp's behind another control didn't pan out, I was thinking, maybe I could leave them visible but shift them off-screen. Can't take the time to go into it now, though. (I'd need to play with things like Tab Stop and so on.)
NeoPa 32,556
Recognized Expert Moderator MVP
Try this : - 'SetVal sets the value of a control even if it's hidden.
-
Public Sub SetVal(ctlThis As Control, varValue As Variant)
-
Dim blnVisible As Boolean
-
-
With ctlThis
-
blnVisible = .Visible
-
.Visible = True
-
.Value = varValue
-
.Visible = blnVisible
-
End With
-
End Sub
I don't know if this is a lot more elegant than your version but it certainly worked for me (except I didn't set up a DT Picker control - just tested it on a TextBox).
...I don't know if this is a lot more elegant than your version but it certainly worked for me (except I didn't set up a DT Picker control - just tested it on a TextBox).
No offence, but I'm not going to bother trying. During testing on the DTPicker, one of the things I tried placing over it was a text box. The DTPicker just seems to bust through everything, including textboxes.
For now I'm just going to go with my current solution, which looks as though it works, even if it is ugly behind the scenes. It's not worth rewriting over and over.
Actually, now that I come to read it, your solution is the same one I'm using. The only difference is that I'm testing the visibility and only changing it when necessary. I've always been under the impression that setting control properties is slow compared to reading them or playing with variables, and so avoid it whenever possible.
Ever though to switch to an all Access calendar like the one from: http://www.mvps.org/access/forms/frm0050.htm
(keep shift pressed, otherwise there's an error...)
Thanks for that Nico. I'll be curious to have a look at it, when I can find time. But for now I'll be sticking with the workaround I've got, since it has the advantage of already having been done. :)
nico5038 3,080
Recognized Expert Specialist
No thanks needed :-)
I stopped using the dtpicker as it won't work on all PC's. In general I try to work without ocx controls as much as possible to limit dependencies to the .dll hell :-)
With A2007 this trouble is "solved" as every date datatype will get a calendar control automatically.
Nic;o)
...With A2007 this trouble is "solved" as every date datatype will get a calendar control automatically.
I don't suppose they've overcome the old 2GB limitation? Even 4GB would be some improvement.
nico5038 3,080
Recognized Expert Specialist
Not that I know of. Guess they won't do much effort for the Jet engine as they want to sell MS SQL <LOL>
Nic;o)
Not that I know of. Guess they won't do much effort for the Jet engine as they want to sell MS SQL
Yeah, that's what I figured.
NeoPa 32,556
Recognized Expert Moderator MVP
No offence, but I'm not going to bother trying. During testing on the DTPicker, one of the things I tried placing over it was a text box. The DTPicker just seems to bust through everything, including textboxes.
For now I'm just going to go with my current solution, which looks as though it works, even if it is ugly behind the scenes. It's not worth rewriting over and over.
Actually, now that I come to read it, your solution is the same one I'm using. The only difference is that I'm testing the visibility and only changing it when necessary. I've always been under the impression that setting control properties is slow compared to reading them or playing with variables, and so avoid it whenever possible.
That's fine Killer.
I didn't get to see your code so didn't know what you'd come up with.
I worked on the basis that as a form is user operated, the efficiency of the routine (with unnoticeable levels of delay) was secondary to the tidyness of the code. You obviously have something just as good already (No surprise there really :)) so that's ok.
...I didn't get to see your code so didn't know what you'd come up with.
What's that? Posting without reading everything first? I'm shocked! ;)
NeoPa 32,556
Recognized Expert Moderator MVP
I saw your pseudo-code, the outline thinking.
Wasn't sure what you actually came up with.
I saw your pseudo-code, the outline thinking.
Wasn't sure what you actually came up with.
Ah. Well, in the end I copied the pseudo-code pretty closely. Um.. hang on... - Public Sub Set_DTP_Value(ctl As Control, ByVal NewValue As Date)
-
' Since I have so much trouble setting the value of my datetimepicker
-
' controls due to this exteremely annoying and STUPID limitation
-
' in Access that they have to be visible, I've written this litte
-
' generic routine to take a datetimepicker (actually, it will accept
-
' any type of control, but I don't recommend it) and set the value,
-
' turning the visibility on and off as required to (A) allow the change,
-
' and (B) maintain the controls original state.
-
Dim HoldVis As Boolean
-
With ctl
-
HoldVis = .Visible
-
If Not HoldVis Then
-
.Visible = True
-
End If
-
.Value = NewValue
-
If Not HoldVis Then
-
.Visible = False
-
End If
-
End With
-
End Sub
As you can see, I'm pretty verbose when it comes to comments. What a surprise! :)
I considered putting some extra code in to safeguard against going outside of the MinDate and MaxDate range, but in the end I didn't bother. There's so much shuffling around of values (with attendant errors due to the aforementioned range limit) that in the end I just set the min and max 'way off in the past and future and left them there.
Of course, the nice thing about having the value-change encapsulated here is that it will be that much simpler (hopefully) if I do decide to modify the method.
NeoPa 32,556
Recognized Expert Moderator MVP
Like the comments ;)
Bear in mind the type of your value parameter (NewValue) for fully generic use.
Like the comments ;)
Bear in mind the type of your value parameter (NewValue) for fully generic use.
In the generic "name the property" version ( see copy below), I used Variant for the value type. Normally I hate variants (probably a sign of age :)) though I guess they do have their uses. But as long as the data type is known (as it is here) I prefer to use it. Oh, I meant to ask - what would be the correct type to use for the dtpicker. In my "real" routine (the one with the long comments) I only used the generic "As Control" because I didn't know the right type. - Public Sub SetValue(ctl As Control, ByVal Prop As String, ByVal NewValue As Variant)
-
Dim HoldVis As Boolean
-
With ctl
-
HoldVis = .Visible
-
If Not HoldVis Then
-
.Visible = True
-
End If
-
.Properties(Prop) = NewValue
-
If Not HoldVis Then
-
.Visible = False
-
End If
-
End With
-
End Sub
NeoPa 32,556
Recognized Expert Moderator MVP
I like that code :)
I wasn't sure you could do that generically but you found a good way.
DTPicker controls - I don't know what they are. ...But if you add a watch to one (or even just to the form) then, when the code is active (in break mode) you can see the type in the Watch Window.
I like that code :)
I wasn't sure you could do that generically but you found a good way.
Thank you. However, if you read an earlier post in this thread, you'll see that it didn't work. But I don't know why.
DTPicker controls - I don't know what they are. ...But if you add a watch to one (or even just to the form) then, when the code is active (in break mode) you can see the type in the Watch Window.
Good point. I'll give it a shot.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: leroybt.rm |
last post by:
Can someone tell me how to run a script from a interactive shell
I type the following:
>>>python filename
>>>python filename.py
>>>run filename
>>>run filename.py
>>>/run filename
>>>/run...
|
by: Ed |
last post by:
Hello,
I took a course in asp about 2 years ago and I was
practicing with IIS 5.0. Then I put it down for a while.
Now trying to get back to it. I can't run asp files from
subdirectories of...
|
by: Jenna Olson |
last post by:
Hi all-
I've never seen this particular issue addressed, but was wondering if
there's anything to support one way or another. Say I have a class:
class ManipulateData
{
public:...
|
by: mg |
last post by:
How can I run an .exe using C# from within the code behind of a WebForm app?
|
by: orekin |
last post by:
Hi There
I have been trying to come to grips with Application.Run(),
Application.Exit() and the Message Pump and I would really appreciate
some feedback on the following questions .. There are...
| |
by: shank |
last post by:
What is the proper syntax to run this command line in ASP?
wzzip.exe File.zip File.txt
thanks
|
by: Bryan |
last post by:
How can i run a bit of code straight from the IDE? Right now i make a
temporary button and put the code behind that, then i run debug mode
and click on the button. Is there a way to highlight...
|
by: Brett Wesoloski |
last post by:
I am new to VS2005.
I changed my program.cs file to be a different form I am working on. But
when I go to run the application it still brings up the form that was
originally declared as new. ...
|
by: Lee Crabtree |
last post by:
I remember when I was first getting into .NET Forms programming that
there was a rather emphatic rule about not constructing a form before
calling Application.Run with it. So this:
...
|
by: mxdevit |
last post by:
Task: run application from ASP.NET
for example,
you have a button on ASP.NET page, when press this button - one
application is invoked.
the code to run application (for example, notepad) is...
|
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: 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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |