How to create a button which mimics a keyboard key

hooolagon

New member
Local time
Today, 17:45
Joined
May 7, 2017
Messages
6
I want to place 4 buttons on my form, with an on click event which basically presses an arrow key. One button for each arrow.

SendKeys doesn't work, and vbKeyUp/vbKeyLeft/vbKeyDown dont seem to run when I Call them..................

Thanks
 
And similarly an easier obstacle... How to enter numbers into a textbox sequentially with buttons on the form representing numbers 1-9 and 0

I will begin my research and get back if I find anything first.

Cheers
 
For your second task, where the Textbox to be populated is named TargetTextbox:

Code:
Private Sub Add1_Click()
  Me.TargetTextbox = Nz(Me.TargetTextbox, "") & "1"
End Sub

Private Sub Add2_Click()
  Me.TargetTextbox = Nz(Me.TargetTextbox, "") & "2"
End Sub

Private Sub Add3_Click()
  Me.TargetTextbox = Nz(Me.TargetTextbox, "") & "3"
End Sub
As to your first task, not really sure. What, exactly, are you trying to accomplish with this, i.e. what do you want to happen when, for instance, the 'down' button is pressed?

Linq ;0)>
 
Wow, awesome, thank you.. I figured I didn't need to mimic the keyboard up arrow, as I could just run a command to navigate my form table (I used acCmdRecordGoTo)

and you can laugh at how I managed to solve my second riddle, compared to yours

Code:
    Dim boxasstring As String
    Dim boxoption1 As String
    Dim boxoption2 As String
    Dim numberone As String

    numberone = "1"
    
    'If textbox is empty change string, otherwise concatenate
    If IsNull(myTextBoxName) Then
        boxoption1 = numberone
        Me.myTextBoxName= boxoption1
    Else
        boxasstring = Me.myTextBoxName
        boxoption2 = boxasstring & numberone
        Me.myTextBoxName= boxoption2
    End If

I guess you truncated my poor coding, appreciate it
 
Also should I use vbNullString where you have "", I read somewhere "" uses like 6 bytes of RAM and is only helpful when ""Thee API"" doesnt support vbNullString (equivalent to C# NULL)

idk.
 

Users who are viewing this thread

Back
Top Bottom