Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 09-18-2019, 08:00 AM   #1
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 332
Thanks: 27
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Populate the name of the active control on focus in a form.

Hi,

I have a form with many field and I would like to know if it's possible to populate the name of that field once we click on that field?

Is there any fire event that capture each time we navigate through different field?

Thanks

calvinle is offline   Reply With Quote
Old 09-18-2019, 08:03 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,410
Thanks: 58
Thanked 1,408 Times in 1,389 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Populate the name of the active control on focus in a form.

Hi. One event you could try to use is the controls GotFocus event.
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 09-18-2019, 08:08 AM   #3
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 332
Thanks: 27
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Re: Populate the name of the active control on focus in a form.

Yes, but I have to set the function to populate the field name on each of the field. Isnít there an event on the form itself that detects each time we move between field?

Thanks

calvinle is offline   Reply With Quote
Old 09-18-2019, 08:20 AM   #4
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,410
Thanks: 58
Thanked 1,408 Times in 1,389 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Populate the name of the active control on focus in a form.

Quote:
Originally Posted by calvinle View Post
Yes, but I have to set the function to populate the field name on each of the field. Isnít there an event on the form itself that detects each time we move between field?

Thanks
Hi. Nothing that I am aware of. What do you mean by "populate the field name on each of the field?"
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 09-18-2019, 08:30 AM   #5
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 332
Thanks: 27
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Re: Populate the name of the active control on focus in a form.

In a continuous form, I can write:
[control].[Form]![field name] then it will populate that field.

On a single form, I have multiple field on the firm. I want the form to prompt the name of the field I am currently in. Once I go to another field, it will prompt the name of the field.

Example prompt:
You are in emp_id.
You are in hr_name.

Etc...
calvinle is offline   Reply With Quote
Old 09-18-2019, 08:31 AM   #6
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 1,888
Thanks: 38
Thanked 571 Times in 538 Posts
MajP has a spectacular aura about MajP has a spectacular aura about
Re: Populate the name of the active control on focus in a form.

If you make a single function

Public SomeFunction()
msgbox activecontrol.name
end function

Then in design view select all the textboxes you want.
In the gotfocus event type
=SomeFunction()

all controls react to the same function
MajP is online now   Reply With Quote
Old 09-18-2019, 08:34 AM   #7
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,410
Thanks: 58
Thanked 1,408 Times in 1,389 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Populate the name of the active control on focus in a form.

Quote:
Originally Posted by calvinle View Post
In a continuous form, I can write:
[control].[Form]![field name] then it will populate that field.

On a single form, I have multiple field on the firm. I want the form to prompt the name of the field I am currently in. Once I go to another field, it will prompt the name of the field.

Example prompt:
You are in emp_id.
You are in hr_name.

Etc...
Hi. Would MajP's suggestion work for you?

__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
Old 09-18-2019, 08:45 AM   #8
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 332
Thanks: 27
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Re: Populate the name of the active control on focus in a form.

Hi,

Nope it does not. I get error message:
The expression you entered has a function containing the wrong number of arguments.

Thanks
calvinle is offline   Reply With Quote
Old 09-18-2019, 08:51 AM   #9
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,569
Thanks: 68
Thanked 2,745 Times in 2,630 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Populate the name of the active control on focus in a form.

create a public function.
add code:

public function fncFieldName() As String
fncFieldName = screen.activecontrol.controlsource
end function
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 09-18-2019, 09:03 AM   #10
MajP
Newly Registered User
 
Join Date: May 2018
Location: USA baby
Posts: 1,888
Thanks: 38
Thanked 571 Times in 538 Posts
MajP has a spectacular aura about MajP has a spectacular aura about
Re: Populate the name of the active control on focus in a form.

Sorry typo
Private Function SomeFunction()
MajP is online now   Reply With Quote
Old 09-18-2019, 11:11 AM   #11
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 332
Thanks: 27
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Re: Populate the name of the active control on focus in a form.

Quote:
Originally Posted by arnelgp View Post
create a public function.
add code:

public function fncFieldName() As String
fncFieldName = screen.activecontrol.controlsource
end function
Thanks this works, but I forgot to mention that the field is in a subform. The code works when I open the subform by itself but when its in a form as subform, the active capture the form as active form, so it doesnt work.
calvinle is offline   Reply With Quote
Old 09-18-2019, 11:14 AM   #12
arnelgp
error reading drive A:
 
arnelgp's Avatar
 
Join Date: May 2009
Location: somewhere out there
Posts: 8,569
Thanks: 68
Thanked 2,745 Times in 2,630 Posts
arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice arnelgp is just really nice
Re: Populate the name of the active control on focus in a form.

do you have any code where you display/msg the controlname? can i have a peek?
__________________
"Never stop learning, because life never stops teaching"
arnelgp is offline   Reply With Quote
Old 09-18-2019, 11:33 AM   #13
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 332
Thanks: 27
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Re: Populate the name of the active control on focus in a form.

Hi,

I have attached an example of what I am trying to achieve.
If you open the "client_subfrm", and click on any field, the "Hint" will lookup in the table for hint, but if you open the main form which is supplier_frm, it won't work.

Can you take a look.

Thanks
Attached Files
File Type: accdb Test.accdb (504.0 KB, 7 views)
calvinle is offline   Reply With Quote
Old 09-18-2019, 04:47 PM   #14
missinglinq
AWF VIP
 
missinglinq's Avatar
 
Join Date: Jun 2003
Location: Richmond (Virginia that is!)
Posts: 6,319
Thanks: 11
Thanked 721 Times in 671 Posts
missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light missinglinq is a glorious beacon of light
Re: Populate the name of the active control on focus in a form.

You could display each Control's name (or anything else you'd like) in the Control itself, when the Record loads, by, in each Control's Format Property, simply entering the name, or whatever, like this

@;"Your Prompt Goes Here"

The name or prompt will disappear when Control is entered...reappear when Control is left, if no data has been entered. Also, if no data is entered...the field bound to the Control remains Null.

Linq ;0)>
__________________
The Devil's in the Details!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


(All code solutions tested in Access 2003/2007, before posting, unless otherwise noted.)
missinglinq is offline   Reply With Quote
Old 09-18-2019, 04:58 PM   #15
calvinle
Newly Registered User
 
Join Date: Sep 2014
Posts: 332
Thanks: 27
Thanked 4 Times in 4 Posts
calvinle is on a distinguished road
Re: Populate the name of the active control on focus in a form.

Quote:
Originally Posted by missinglinq View Post
You could display each Control's name (or anything else you'd like) in the Control itself, when the Record loads, by, in each Control's Format Property, simply entering the name, or whatever, like this

@;"Your Prompt Goes Here"

The name or prompt will disappear when Control is entered...reappear when Control is left, if no data has been entered. Also, if no data is entered...the field bound to the Control remains Null.

Linq ;0)>
Right but I want to display an hint by using a dlookup from a table (see my attachment). In the futur, if there is changes in the hint, they can simply change in the table without the need to throw out a new version of the front end.

calvinle is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
External Module select control on active form Cowboy_BeBa Modules & VBA 4 08-09-2016 04:40 AM
[SOLVED] Set Focus to control on sub form Derrick T. Davidson Modules & VBA 1 02-08-2016 03:07 AM
Finding the previous active control on a form IanHem Forms 2 03-02-2015 07:27 AM
Assigning value to active control on another form highandwild Forms 1 03-25-2010 12:10 PM
Addressing an active form control from a query Maurog Forms 5 06-25-2004 07:31 AM




All times are GMT -8. The time now is 10:24 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World