form on got focus set control to "yes"

Leo_Polla_Psemata

Registered User.
Local time
Yesterday, 22:08
Joined
Mar 24, 2014
Messages
364
Hi
I have a form
In this form there is a yes/no control

I want to turn it to "yes" when on got focused in this form
and
turn it to "no" when lost focus.

It must be an easy one, could somebody enlighten me ?
 
Use the On_Got Focus and On_Lost_Focus events ?
What is a Yes No control - is it a text box or a check box ?
 
In the got focus event.

Code:
Me.TheNameOfTheCheckBox = True

on lost focus

Code:
Me.TheNameOfTheCheckBox = False

To give the check box a (better) name go the checkbox's properties Other Tab
 
Hi
Thanks for the input

In fact , the "on got focus" doesn't work, it works on the "on current"

This works

Private Sub Form_Current()
Me.fo = True
End Sub

This doesn't work

Private Sub Form_GotFocus()
Me.fo = True
End Sub

May be the "Got Focus" event is not what I thought

Now, the "got focus has an opposite, "lost forcus
Which is the opposite of Current event ?
 
On Current is when the form moves between records, there isn't a opposite of it.
I understand English is probably not your first language, so maybe we have misinterpreted what you where trying to achieve?
Possibly post up a picture of your form and what you are trying to do?
 
Hi
Indeed, not English native speaker, not IT nor programmer , just user who have found in access and VBA a very helpful assistant .

On_Got_Focus.jpg

On_Got_Focus.jpg


See this picture
I want, when I click to one record, the checkbox to go true, then, once i click to the next record, the "lost focus" record to go false and the "on got focus" to go true.
So, every time ONLY ONE record will be trus, the one I am focused on.
 
Okay I understand - Can I ask what purpose this will serve? Is it to only let the command button work on the current record? If so there are better ways to achieve this.
If it is to stop the command button working on other records - I'm afraid it won't work, as as soon as the button gets focus the current record will be the one you are on.
 
Hi Mindy

I have opened a new tread for this
http://www.access-programmers.co.uk/forums/showthread.php?t=288905

I want to compose emails where in the body email the information is displayed.
You see, attachments is not workable because too many clients follow emails through mobiles, they dont open attachments.

I have been using a code.

This time, the query is "=Forms!FormName.Text1"
and the code doesn't work.
If I type criteria it works but with =Forms!FormName.Text1, no
I thought if it could be easy to make a checkbox turn to true when I am on a specific record and turn to false if leave this record.
In this case the query would work and supply data to the code and mbam... the email is ready.

In other words

I want to reach to a result like this =Forms!FormName.Text1
without using this syntax in my query.
 
Hi
With this code i reached to my point
The "on focus" record is foc yes and the query which supplies the data to email works perfect, thanks anyway

Private Sub Command13_Click()

Me.foc1 = False
DoCmd.GoToRecord , , acNext
Me.foc1 = True

End Sub

Private Sub Command14_Click()

Me.foc1 = False
DoCmd.GoToRecord , , acPrevious
Me.foc1 = True

End Sub
 
...May be the "Got Focus" event is not what I thought...

The problem, here, is that a Form can only receive Focus if there are no Controls on it that can receive Focus...and your Form has such a Control, hence the Form cannot receive Focus and the OnGotFocus event doesn't fire!

So, if a Form only contains Labels (such as a Splash Screen might) or if all Controls, such as Textboxes, Checkboxes, Comboboxes, etc., have their Enabled Property set to No, the Form itself can receive Focus.

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom