473,498 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Run-time error '2763' setting date/time picker value.

8,435 Recognized Expert Expert
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
Expand|Select|Wrap|Line Numbers
  1. Run-time error '2763':
  2.  
  3. DTPicker returned the error: An error occurred in a call to the Windows
  4. 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.
Jan 22 '07 #1
26 13197
Killer42
8,435 Recognized Expert Expert
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...
Jan 22 '07 #2
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)
Jan 22 '07 #3
Killer42
8,435 Recognized Expert Expert
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! :)
Jan 22 '07 #4
Killer42
8,435 Recognized Expert Expert
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.
Jan 22 '07 #5
Killer42
8,435 Recognized Expert Expert
P.S. The various controls that I tried did cover up the dtpicker at design time, but at runtime, no-go.
Jan 22 '07 #6
nico5038
3,080 Recognized Expert Specialist
And hiding the form, then set the dtpickers and then show the form ?

Nic;o)
Jan 22 '07 #7
Killer42
8,435 Recognized Expert Expert
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. :(
Jan 23 '07 #8
Killer42
8,435 Recognized Expert Expert
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
Expand|Select|Wrap|Line Numbers
  1. Hold the value of .Visible property
  2. If it's hidden Then
  3.   Set .Visible to True
  4. End If
  5. Set .Value to passed value
  6. If it was originally hidden Then
  7.   Set .Visible = False
  8. 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.
Jan 23 '07 #9
Killer42
8,435 Recognized Expert Expert
...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... :(
Jan 23 '07 #10
Killer42
8,435 Recognized Expert Expert
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.)
Jan 23 '07 #11
NeoPa
32,556 Recognized Expert Moderator MVP
Try this :
Expand|Select|Wrap|Line Numbers
  1. 'SetVal sets the value of a control even if it's hidden.
  2. Public Sub SetVal(ctlThis As Control, varValue As Variant)
  3.     Dim blnVisible As Boolean
  4.  
  5.     With ctlThis
  6.         blnVisible = .Visible
  7.         .Visible = True
  8.         .Value = varValue
  9.         .Visible = blnVisible
  10.     End With
  11. 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).
Jan 23 '07 #12
nico5038
3,080 Recognized Expert Specialist
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...)

Nic;o)
Jan 23 '07 #13
Killer42
8,435 Recognized Expert Expert
...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.
Jan 23 '07 #14
Killer42
8,435 Recognized Expert Expert
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. :)
Jan 23 '07 #15
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)
Jan 23 '07 #16
Killer42
8,435 Recognized Expert Expert
...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.
Jan 23 '07 #17
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)
Jan 23 '07 #18
Killer42
8,435 Recognized Expert Expert
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.
Jan 23 '07 #19
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.
Jan 23 '07 #20
Killer42
8,435 Recognized Expert Expert
...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! ;)
Jan 23 '07 #21
NeoPa
32,556 Recognized Expert Moderator MVP
I saw your pseudo-code, the outline thinking.
Wasn't sure what you actually came up with.
Jan 23 '07 #22
Killer42
8,435 Recognized Expert Expert
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...
Expand|Select|Wrap|Line Numbers
  1. Public Sub Set_DTP_Value(ctl As Control, ByVal NewValue As Date)
  2.   ' Since I have so much trouble setting the value of my datetimepicker
  3.   ' controls due to this exteremely annoying and STUPID limitation
  4.   ' in Access that they have to be visible, I've written this litte
  5.   ' generic routine to take a datetimepicker (actually, it will accept
  6.   ' any type of control, but I don't recommend it) and set the value,
  7.   ' turning the visibility on and off as required to (A) allow the change,
  8.   ' and (B) maintain the controls original state.
  9.   Dim HoldVis As Boolean
  10.   With ctl
  11.     HoldVis = .Visible
  12.     If Not HoldVis Then
  13.       .Visible = True
  14.     End If
  15.     .Value = NewValue
  16.     If Not HoldVis Then
  17.       .Visible = False
  18.     End If
  19.   End With
  20. 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.
Jan 23 '07 #23
NeoPa
32,556 Recognized Expert Moderator MVP
Like the comments ;)
Bear in mind the type of your value parameter (NewValue) for fully generic use.
Jan 23 '07 #24
Killer42
8,435 Recognized Expert Expert
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.


Expand|Select|Wrap|Line Numbers
  1. Public Sub SetValue(ctl As Control, ByVal Prop As String, ByVal NewValue As Variant)
  2.   Dim HoldVis As Boolean
  3.   With ctl
  4.     HoldVis = .Visible
  5.     If Not HoldVis Then
  6.       .Visible = True
  7.     End If
  8.     .Properties(Prop) = NewValue
  9.     If Not HoldVis Then
  10.       .Visible = False
  11.     End If
  12.   End With
  13. End Sub
Jan 23 '07 #25
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.
Jan 23 '07 #26
Killer42
8,435 Recognized Expert Expert
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.
Jan 23 '07 #27

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

Similar topics

3
4911
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...
4
3200
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...
2
2519
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:...
15
4263
by: mg | last post by:
How can I run an .exe using C# from within the code behind of a WebForm app?
6
20035
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...
9
19656
by: shank | last post by:
What is the proper syntax to run this command line in ASP? wzzip.exe File.zip File.txt thanks
19
2199
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...
9
4653
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. ...
7
2925
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: ...
7
11724
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...
0
6993
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
7162
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
7375
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...
1
4899
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
4584
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...
0
3088
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...
0
1411
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 ...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
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...

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.