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

I want to know if I'm in a specific field on a form

100+
P: 443
I'm using the Calendar (ocxcalendar). I have five calendar fields on my form and I would like to use just one calendar and put an If statement as to what field I'm in. How do I do this? This is probably very simple but for the life of me I don't seem to be able to make it work.

Thanks for any help.
Jan 19 '16 #1

✓ answered by jforbes

I'm not quite sure what you are asking about. If you want to get the name of the control that currently has focus, you can use:
Expand|Select|Wrap|Line Numbers
  1. Screen.ActiveControl.Name
or for the previous control:
Expand|Select|Wrap|Line Numbers
  1. Screen.PreviousControl.Name

Share this Question
Share on Google+
7 Replies


NeoPa
Expert Mod 15k+
P: 31,560
I use one that's a derivation of one that I inherited. The original call to the code passes the control as a parameter which is stored locally in the form.

It's a roll-your-own one using a simple Form.
Jan 20 '16 #2

jforbes
Expert 100+
P: 1,107
I'm not quite sure what you are asking about. If you want to get the name of the control that currently has focus, you can use:
Expand|Select|Wrap|Line Numbers
  1. Screen.ActiveControl.Name
or for the previous control:
Expand|Select|Wrap|Line Numbers
  1. Screen.PreviousControl.Name
Jan 20 '16 #3

NeoPa
Expert Mod 15k+
P: 31,560
I considered posting something on those lines, JForbes, but couldn't see how the control referred to could be the active control as the calendar control would be. That said, I guess Tom must have got something from that as he's flagged it as the best answer.

Maybe the PreviousControl is what he likes it for. I don't know that object well enough to know if that can be guaranteed to be the one that triggered the calendar but it certainly would be in most cases. If not then passing a reference in the call might still make the most sense.
Jan 20 '16 #4

100+
P: 443
I was able to use the previouscontrol and it worked just like I wanted it to. Thanks for all the help
Jan 21 '16 #5

jforbes
Expert 100+
P: 1,107
Glad you got it working. I just took a stab at it.

I've never used the Calendar control. I've looked at it, but it didn't thrill me enough to move away from the .ShowDatePicker property built into the TextBox control.
Jan 21 '16 #6

100+
P: 443
I would be interested in ShowDatePicker as I'm having problems with the calendar when I try and compile the program using Access 2016 64bit version. I have a couple of users that have purchased the office 365 in 64bit and because they are using it with another database they have a problem switching between the two. When in my database it installs the runtime and then when they go back to their other version it tries to reinstall the 64bit version and they have to load it.
If you are anyone has had problems switching I would be interested in any help. I get type mismatch errors when compiling also.
Jan 21 '16 #7

NeoPa
Expert Mod 15k+
P: 31,560
It's a minefield Tom. Be very careful.

That said, there is help out there. You may struggle finding all the relevant stuff though.

Good luck anyway :-)
Jan 22 '16 #8

Post your reply

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