By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

Controls Flying?

P: 77
Guys,

I'm facing a wierd problem and don't exactly know where the glitch is.

I have a form with Tab control in Access 2003. In each tab, I have a text box and two Datepicker controls. The wierd part is that sometimes (not all the times), as soon as I press the Tab key in the textbox, the Datepicker controls "Fly" to the topmost left corner of the form. I have checked every bit n piece of the code that I have written, but nowhere am I changing the position of the controls.

The following is the code written for the Text Box:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtEmpIDATT_Exit(Cancel As Integer)
  2.     If txtEmpIDATT.Text = "" Then
  3.         'do nothing
  4.     Else
  5.         Call cmdHidden1_Click
  6.     End If
  7. End Sub
  8.  
  9. Private Sub cmdHidden1_Click()
  10.     On Error GoTo errr
  11.     Call conDB
  12.     EID = Trim(txtEmpIDATT.Text)
  13.     vSQL = "select emp_name,function from emp_master where emp_id=" & EID
  14.     Set rsMain = conMain.Execute(vSQL)
  15.     If rsMain.BOF = True Then
  16.         MsgBox "Either the Employee ID is incorrect or the employee doesn't exist in records.", vbCritical, "Employee ID"
  17.         Call att_reset
  18.     Else
  19.         txtEmpNameAtt.Caption = rsMain(0) & "/" & rsMain(1)
  20.         DTLWD.Enabled = True
  21.         DTDOA.Enabled = True
  22.         If rsMain(1) = "Attrition" Then
  23.             MsgBox "This employee has already attrited.", vbCritical, "Attrition"
  24.             Call att_reset
  25.         Else
  26.             'do nothing
  27.         End If
  28.     End If
  29.     Exit Sub
  30. errr:
  31.     MsgBox Err.Description
  32.     Set rsMain = Nothing
  33.     Set conMain = Nothing
  34. End Sub
  35.  
  36. Private Sub att_reset()
  37.     txtEmpIDATT.SetFocus
  38.     txtEmpIDATT.Text = ""
  39.     txtEmpNameAtt.Caption = ""
  40.     DTLWD.Enabled = False
  41.     DTDOA.Enabled = False
  42. End Sub
  43.  
  44.  
I'm also attaching the screenshots of the form for reference.

Hoping someone would have a clue and come up with a solution please......

Thanks.......
Attached Files
File Type: zip Flying.zip (17.6 KB, 75 views)
Sep 4 '08 #1
Share this Question
Share on Google+
31 Replies


Expert Mod 2.5K+
P: 2,545
Hi Yaaara. Nothing obvious jumps out from your code.

You'll need to check the LEFT and TOP attributes of the controls concerned. You can add before and after msgbox statements in your code to see if this sheds any light on it, like this:

Expand|Select|Wrap|Line Numbers
  1. with Me![yourtextboxname]
  2.   msgbox("Left = " & .Left & " Top = " & .Top)
  3. end with
As a start you could place code like this in the On Focus and After Update events of your textboxes. If the Left or Top attributes are different something has changed them - then the debug checks begin in earnest...

If not there is a bug of some kind somewhere...

-Stewart
Sep 4 '08 #2

P: 77
Thanks for the prompt response Stewart, but this doesn't happen all the time. Had this been happening every time, I would have assumed that there is something to do with the Left & the Top attributes.. Its just at random times that this happens while at other times, the controls stay where they are supposed to be...

Hi Yaaara. Nothing obvious jumps out from your code.

You'll need to check the LEFT and TOP attributes of the controls concerned. You can add before and after msgbox statements in your code to see if this sheds any light on it, like this:

Expand|Select|Wrap|Line Numbers
  1. with Me![yourtextboxname]
  2.   msgbox("Left = " & .Left & " Top = " & .Top)
  3. end with
As a start you could place code like this in the On Focus and After Update events of your textboxes. If the Left or Top attributes are different something has changed them - then the debug checks begin in earnest...

If not there is a bug of some kind somewhere...

-Stewart
Sep 4 '08 #3

P: 77
I also put the code you advised in the GotFocus, AfterUpdate and Exit events of the text box..

To my surprise, the message box pops up with the attributes in the GotFocus event, but not for any other events.. Not sure why this is happening..

Any clues?

Thanks for the prompt response Stewart, but this doesn't happen all the time. Had this been happening every time, I would have assumed that there is something to do with the Left & the Top attributes.. Its just at random times that this happens while at other times, the controls stay where they are supposed to be...
Sep 4 '08 #4

P: 77
Also, when I Tab out of the text box and the control has moved, when I click on the Text box again (To invoke the GotFocus event), the message box pops up again with the same Left and Top values for the datepicker control like the way it was before movement...



I also put the code you advised in the GotFocus, AfterUpdate and Exit events of the text box..

To my surprise, the message box pops up with the attributes in the GotFocus event, but not for any other events.. Not sure why this is happening..

Any clues?
Sep 4 '08 #5

Expert Mod 2.5K+
P: 2,545
Hi Yaaara. I do understand that it is just sometimes. In my view, either there is a bug in the product, or there is something changing the physical position of your controls. You need to eliminate or reduce the possibilities systematically, no matter how infrequently the problem is occurring.

I have used tabbed pages in Access 2003 applications for some time. In more than nine months of use of one application by five users I have never experienced such a failure, nor have I heard of it before, nor (as far as I know) has it been identified by other posters to Bytes in the past six months.

If I was in your position I would be deliberately trying to induce failure so that the debug code can assist in verification of whether or not the Left and Top attributes are as expected. If they are not, I repeat, something has changed them - and you need to find what it is. If they are the same, you will have eliminated control position as the problem - and you then need to deal with whether or not there is a bug in Access itself that could be causing the failure.

-Stewart
Sep 4 '08 #6

P: 77
How can we find whether it is a known bug or something else?

Hi Yaaara. I do understand that it is just sometimes. In my view, either there is a bug in the product, or there is something changing the physical position of your controls. You need to eliminate or reduce the possibilities systematically, no matter how infrequently the problem is occurring.

I have used tabbed pages in Access 2003 applications for some time. In more than nine months of use of one application by five users I have never experienced such a failure, nor have I heard of it before, nor (as far as I know) has it been identified by other posters to Bytes in the past six months.

If I was in your position I would be deliberately trying to induce failure so that the debug code can assist in verification of whether or not the Left and Top attributes are as expected. If they are not, I repeat, something has changed them - and you need to find what it is. If they are the same, you will have eliminated control position as the problem - and you then need to deal with whether or not there is a bug in Access itself that could be causing the failure.

-Stewart
Sep 4 '08 #7

Expert Mod 2.5K+
P: 2,545
Might be worth searching the Microsoft Knowledge Base to find out if there are any known issues with control positioning.

It is interesting that both controls appear to be forced to the same top-left location when this happens; is there any other control placed on the form nearby on a hidden basis which might be causing interference here?

-Stewart
Sep 4 '08 #8

P: 77
No other control exists on the form... Interesting for me too as I encountered this situation for the first time... I hope to find something at the MS Knowledge Base.. Will surely let all know if any information is found..

Thanks for your prompt response anyways :-)

Might be worth searching the Microsoft Knowledge Base to find out if there are any known issues with control positioning.

It is interesting that both controls appear to be forced to the same top-left location when this happens; is there any other control placed on the form nearby on a hidden basis which might be causing interference here?

-Stewart
Sep 4 '08 #9

P: 77
All I could find was the following article BUG: Office repaint problem if modal form is shown from ActiveX EXE

Although I don't think this applies directly to my issue, it may be related.. Any suggestions?

No other control exists on the form... Interesting for me too as I encountered this situation for the first time... I hope to find something at the MS Knowledge Base.. Will surely let all know if any information is found..

Thanks for your prompt response anyways :-)
Sep 4 '08 #10

Expert Mod 2.5K+
P: 2,545
Reviewing the article I doubt it applies in your circumstances, but can't be sure. I'll ask colleagues on the Forum for their opinion to see if they have any better ideas about what might be happening.

-Stewart
Sep 4 '08 #11

P: 77
Thanks a ton Stuart.. Any help will be highly appreciated :-)

Reviewing the article I doubt it applies in your circumstances, but can't be sure. I'll ask colleagues on the Forum for their opinion to see if they have any better ideas about what might be happening.

-Stewart
Sep 4 '08 #12

nico5038
Expert 2.5K+
P: 3,072
Hmm, quite extraordinary and never seen before.
(And I've used tabbed controls intensively..)

My first impression is an Access failure and a sign of a corrupt database.
I would execute my set of standard "corrupt database steps":
1) Create a backup of the corrupt database. (Just in case of)

2) Create a new database and use File/Get external data/Import to get all objects of the damaged database.

3) Try these Microsoft solutions:
Repair A97/A2000:
http://support.microsoft.com/support.../Q109/9/53.asp
Jetcomp:
http://support.microsoft.com/default...;en-us;Q273956
and/or read the article:
ACC2000: How to Troubleshoot Corruption in a Microsoft Access Database
http://support.microsoft.com/default...b;en-us;306204
(Or look for similar info on 2003 when you use that)

4) Bit "heavier":
Access decompile:
http://www.granite.ab.ca/access/decompile.htm


check also: http://www.granite.ab.ca/access/corruptmdbs.htm

Sometimes a complete reinstall of Office solved strange problems for me too.

Nic;o)
Sep 4 '08 #13

missinglinq
Expert 2.5K+
P: 3,532
I've used tabbed forms for years and have never experienced anything like this nor have I read reports of this type of behavior anywhere. My first thought was identical to Nico's, that we're dealing with some type of corruption.

Probably worth trying the old create-a-blank-database-and-import-everything-into-it routine before doing anything else. Actually, might be worthwhile to first try deleting then re-creating the offending textbox.

Linq ;0)>
Sep 4 '08 #14

P: 77
Guys, Thanks for your inputs on this..

Just to clarify, its not the textbox but the Datepicker control which is flying around. (may be this changes some thoughts?)
Also, there are two datepicker controls in each tab (5 tabs in all, so 10 controls) and each one acts up randomly.
Also, it is a fresh installation of Office 2003.
I have tried Compacting and Repairing the database using the usual menu option.
After going through the advise by Nico, I tried the create-a-blank-database-and-import-everything-into-it routine, but same result.

I'm constantly looking up the MS Knowledgbase articles to find something meanwhile.. The problem is wierd, I know, but then that's the way it is at the moment :-(

I've used tabbed forms for years and have never experienced anything like this nor have I read reports of this type of behavior anywhere. My first thought was identical to Nico's, that we're dealing with some type of corruption.

Probably worth trying the old create-a-blank-database-and-import-everything-into-it routine before doing anything else. Actually, might be worthwhile to first try deleting then re-creating the offending textbox.

Linq ;0)>
Sep 4 '08 #15

nico5038
Expert 2.5K+
P: 3,072
Then I would now try the Access decompile, or try to change the datepicker's dll/ocx to a (newer) verion.

Personally I never use this (and other .ocx) controls as it's making the running of the databaseon another PC dpending on the installed .dll's (they have a reason to call this the ".dll hell").

I use for datetime picking the control fro www.mvps.org/access and have a sample attached that's a stripped down version. As it's "all Access" the portability of the control is 100%.

Nic;o)
Attached Files
File Type: zip MiniCalendar2000.zip (17.5 KB, 63 views)
Sep 4 '08 #16

missinglinq
Expert 2.5K+
P: 3,532
Nico's last post made me think about something; you've been calling this a "DatePicker" and we've been assuming that it's an ActiveX control, but is it in fact? I ask because there are custom made datepickers out there that position themselves in relation to the control they're going to populate, and I have heard of problems with them from time to time.

No one has asked, but would it be possible to zip your database up and post it here? This is really one of those times when actually having your hands on the app can make a big difference in troubleshooting it.

Linq ;0)>
Sep 4 '08 #17

FishVal
Expert 2.5K+
P: 2,653
Hello, yaara.

Do you have a method to reproduce the fault?
If so (and even if you don't), then it may be a good idea to attach sanitized copy of db to the thread.

P.S. Are you sure your DTPickers are bound to the same background as TextBoxes are?

P.P.S. Also, please post library of DTPicker control - name, version, dll/ocx.
Sep 4 '08 #18

NeoPa
Expert Mod 15k+
P: 31,347
I'm just leaving for home so am in a bit of a rush, but there was a call to arms from our revered leader so I will just pop in to suggest something you can try to help you discover what may be causing this anomaly. It is only really effective if it is due to your code, but the debugger (specifically Watch Pane - See Debugging in VBA for more details) has a facility to watch a value, and interrupt execution of the code when that changes for any reason.

I suggest you set up your database with this Watch set and see where the code stops.

Let me know how you get on with this.
Sep 4 '08 #19

missinglinq
Expert 2.5K+
P: 3,532
Only 6:35 PM and already you're heading for home and hearth? I take it France's 35 hour work week hasn't made its way over the Channel yet!

;0)>
Sep 4 '08 #20

P: 77
The control indeed is the Microsoft Date and Time Picker control ver 6.0. It is the default DTPicker that I found in the Access Forms Toolbox List so I used it..

Zipping the database and posting here won't be possible as the database I'm referring to is a different .mdb file and my front end is in a different .mdb file. So If I post my front end, it won't work, and posting the DB would be difficult as it is approx 250+ MB... So not much luck there I guess..

Please let me know if anyone comes across with known issues with this DTPicker control...

Nico's last post made me think about something; you've been calling this a "DatePicker" and we've been assuming that it's an ActiveX control, but is it in fact? I ask because there are custom made datepickers out there that position themselves in relation to the control they're going to populate, and I have heard of problems with them from time to time.

No one has asked, but would it be possible to zip your database up and post it here? This is really one of those times when actually having your hands on the app can make a big difference in troubleshooting it.

Linq ;0)>
Sep 4 '08 #21

P: 77
As far as I know, the DTPickers are bound to the same Tab Control as the Text Boxes, but I'm not sure.. may be they're not? How can I check and make sure that they are? Also, I'd say that even if they are not (let's assume), then ideally they should not change their positions on their own... and that too at random times? That seems wierd, isn't it? But still, if bounding the controls to the Tab Control helps, I'd like to check it out... So pls let me know how to check it and how to make sure that all controls are bound to the same Tab Control...

Thanks :-)

Hello, yaara.

Do you have a method to reproduce the fault?
If so (and even if you don't), then it may be a good idea to attach sanitized copy of db to the thread.

P.S. Are you sure your DTPickers are bound to the same background as TextBoxes are?

P.P.S. Also, please post library of DTPicker control - name, version, dll/ocx.
Sep 4 '08 #22

NeoPa
Expert Mod 15k+
P: 31,347
Only 6:35 PM and already you're heading for home and hearth? I take it France's 35 hour work week hasn't made its way over the Channel yet!

;0)>
7 hour working day - That would be nice :D
Sep 4 '08 #23

Expert Mod 2.5K+
P: 2,545
A big thank you to all my forum colleagues for responding so timeously and helpfully here - you've really helped focus this thread in to what may well be the nub of the problem - interactions of the datepicker controls in some way.

Ever been told you're a great team to work with? I learn a lot from you all even now.

Geesh, gotta go or I'll get even more slushy...

Cheers guys

-Stew
Sep 4 '08 #24

P: 16
Hi yaara
I was having the same problem with datepicker
I finally gave up and used a new form "calendar" to do this

Here is the link to see how it works
http://rapidshare.com/files/143939578/calendar.rar.html
It has two modules
one is for calendar and other is to change the cursor type when u go on the calendar icon
If u wana use this, Import these 2 modules and one form calendar in ur db
and u have the coding how to call it
Sep 4 '08 #25

NeoPa
Expert Mod 15k+
P: 31,347
Sam,

I tried your link and, whether the pop-up would have directed me to a download I don't know, but with pop-ups blocked I was only able to see the sign-up page of that site which is not a valid link (which I have removed).

Please, if you have helpful software to share, consider posting it in the thread. Attachments are also available if the size is not too great.

Administrator.
Sep 4 '08 #26

P: 77
So apparantly, this is a problem with Datepicker?
Sep 5 '08 #27

NeoPa
Expert Mod 15k+
P: 31,347
Only you would know at this stage Yaaara. Have you tried the debugging (Watch Window) technique I suggested (post #19)?
Sep 5 '08 #28

P: 77
Sorry but not sure how to setup the watch window for this Neo :-(

Pls assist...
Sep 5 '08 #29

NeoPa
Expert Mod 15k+
P: 31,347
On one condition :- You stop including quotes of the previous post unless they are relevant. Generally not when your post follows on immediately afterwards. It's only really necessary to indicate a break in flow of the thread, or to draw particular attention to an item as you respond to it.

Anyway - on to the instructions.
  1. Find a value that will change when the item moves. This can be .Top or .Left of the item that moves.
  2. Using Alt-V+H, open the Watch Pane.
  3. Right click within it to add a new watch expression.
  4. Enter the full object address of the .Top or .Left item you're trying to monitor into Expression.
  5. In Procedure & Module select all.
  6. In Watch Type select Break When value Changes
Run the code until the item moves. At this point the code should break leaving you where (or at least near) the point where something strange is happening.

Have fun :)
Sep 5 '08 #30

NeoPa
Expert Mod 15k+
P: 31,347
Hi yaara
I was having the same problem with datepicker
I finally gave up and used a new form "calendar" to do this

Here is the link to see how it works
http://rapidshare.com/files/143939578/calendar.rar.html
It has two modules
one is for calendar and other is to change the cursor type when u go on the calendar icon
If u wana use this, Import these 2 modules and one form calendar in ur db
and u have the coding how to call it
Sam12 supplied me with a new (working) version of the link which I have inserted back into his post.

Check it out.
Sep 9 '08 #31

nico5038
Expert 2.5K+
P: 3,072
Hmm, just another thought, did you check how many date-time controls there are on your form. Are you sure it's no "hidden" control on the top of the form or "behind" the tab control that's "popping" up ?
It's often hard to see, but best to check or, after removing the two visible combo's, this behavior persists.

Nic;o)
Sep 11 '08 #32

Post your reply

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