BFanguy
asked on
Access 2010 Sendkeys Equivalent In VBA, Access 2010
I need VBA code that when a field on a form has focus to Send a F2.
Currently i am using the SendKey (which I know everytime a programmer uses the sendkey function a baby kitten is killed...), but there is a known bug in access 2010 (http://support.microsoft.com/kb/179987) that turns off the num locks and caps locks when using sendkeys.
This is what I am using currently:
If Me.Hardness <> "N/A" And Me.Hardness <> "" Then
SendKeys "{F2}", True
DoEvents
End If
Looking for an alternate method.
Thanks in advance.
Currently i am using the SendKey (which I know everytime a programmer uses the sendkey function a baby kitten is killed...), but there is a known bug in access 2010 (http://support.microsoft.com/kb/179987) that turns off the num locks and caps locks when using sendkeys.
This is what I am using currently:
If Me.Hardness <> "N/A" And Me.Hardness <> "" Then
SendKeys "{F2}", True
DoEvents
End If
Looking for an alternate method.
Thanks in advance.
what do you want to happen if this statement is correct ?
If Me.Hardness <> "N/A" And Me.Hardness <> "" Then
or what do you expect the line > SendKeys "{F2}", True to do ?
If Me.Hardness <> "N/A" And Me.Hardness <> "" Then
or what do you expect the line > SendKeys "{F2}", True to do ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you want to select the text in the field?
ASKER
No thats what access does by default, I just want to put the focus at the end of the field so they can append to the data. i.e. the field may have BHN- alrealy in it, i want them to add a value after BHN- Ex: BHN-253
capricorn1's suggestion works me.hardness.selstart=len(m e.hardness )+1
capricorn1's suggestion works me.hardness.selstart=len(m
want to put the focus at the end of the fieldIf control text is selected, F2 removes deselects text and sets cursor at end of typed text.
Yes, capricorn1's suggestion does work and produces the same behavior.
ASKER