New member with problems

desasurco

New member
Local time
Tomorrow, 02:48
Joined
Jul 10, 2016
Messages
2
Hi all

I am a member who has not posted before.
I have programmed in VBA since access 97 with good results.
I have just changed to a new Surface Book and cannot debug my code as there is no break/pause key on the keyboard,

Can anyone assist on how to get around this ?
 
Try using the on-screen keyboard (as part of the Windows OS, not the tablet's one). I think you can run "osk.exe" from the commandline to open it, but it has been a while.

If it's something you'll be doing a lot of, might be worth picking up a bluetooth keyboard for that has better programming key support.
 
My MS keyboard used with my desktop also has no Break key.
However Ctrl+ScrLk (scroll lock) acts in the same way for debugging code

If that's also not available, you can load an OSK as jleach suggested

As I now use a Windows tablet a lot, I now design my apps so they are tablet compatible (as well as 64-bit compatible).

As part of this I add code to automatically load the on screen keyboard
Add the following to a standard module:

Code:
Option Compare Database
Option Explicit

'Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

'Code Courtesy of Dev Ashish

'###############################################
'Add PtrSafe - required for 64-bit Office (VBA7)
#If VBA7 Then
        Private Declare PtrSafe Function apiShellExecute Lib "shell32.dll" _
        Alias "ShellExecuteA" _
        (ByVal hWnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As Long) _
        As Long
#ElseIf Win64 Then 'need datatype LongPtr
    Private Declare PtrSafe Function apiShellExecute Lib "shell32.dll" _
        Alias "ShellExecuteA" _
        (ByVal hWnd As LongPtr, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As LongPtr) _
        As LongPtr
#Else '32-bit Office
    Private Declare Function apiShellExecute Lib "shell32.dll" _
        Alias "ShellExecuteA" _
        (ByVal hWnd As Long, _
        ByVal lpOperation As String, _
        ByVal lpFile As String, _
        ByVal lpParameters As String, _
        ByVal lpDirectory As String, _
        ByVal nShowCmd As Long) _
        As Long
#End If
'###############################################

Public Sub RunOSK()

'opens on screen keyboard if opened in tablet mode
If modMetrics.System(SM_TABLETPC) Then
   ' MsgBox "Tablet PC"
    apiShellExecute 0, vbNullString, "osk.exe", vbNullString, "C:\", 1
Else
   ' MsgBox "Not a tablet PC"
End If

End Sub

Public Sub ShellEx(ByVal Path As String, Optional ByVal Parameters As String, Optional ByVal HideWindow As Boolean) 'CR v5186

    If Dir(Path) > "" Then
        apiShellExecute 0, "open", Path, Parameters, "", IIf(HideWindow, 0, 1)
    Else
        MsgBox "Can't find program"
    End If

End Sub

Public Function OpenMagnifier()

    ShellEx "c:\windows\system32\magnify.exe", , 0

End Function

Public Sub OpenTabTip()

'opens tablet screen keyboard if opened in tablet mode
If modMetrics.System(SM_TABLETPC) Then
    ShellEx "C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe", , True
Else
   
End If

End Sub

Now you just need to add this line to your form load event
Code:
RunOSK
NOTE - it also doesn't contain a Break key - use ScrLk as above

or for the standard tablet keyboard use thiss instead in the Form_Load event:
Code:
OpenTabTip


NOTE: The module code above uses one line from a modMetrics module. This could be incorporated into the first module but to save time, I'm posting the complete metrics module with additional items

Code:
Option Compare Database
Option Explicit

' Module to provide metrics information (from GetSystemMetrics) and conversions -
'   twips <-> pixel conversions

'  CREATED:  6 march 2004, Paul J. Champion

Public Enum AccessSpecifications
    maxSectionHeight = 31680
    maxFormWidth = 31680
    maxReportWidth = 31680
    RecordSelectorWidth = 300
End Enum
Public Const DefaultMargin = 60 '60 twips = 0.1 cm, a nice small but clear margin
'Public Const AccessSpecifications.maxSectionHeight = 31680

Private Type RECT
  Left As Long
  top As Long
  right As Long
  bottom As Long
End Type

Public Type Size
    Width As Long
    Height As Long
End Type

' TWIPS to PIXELS api declares & constants

'changes for 64-bit
'###############################################
'Add PtrSafe - required for 64-bit Office (VBA7)
#If VBA7 Then
    Private Declare PtrSafe Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    Private Declare PtrSafe Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long) As Long
    Private Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
    
    ' GetSystemMetrics() codes
    Private Declare PtrSafe Function apiGetSystemMetrics Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
#ElseIf Win64 Then 'need datatype LongPtr
    Private Declare PtrSafe Function GetDC Lib "user32" (ByVal hWnd As LongPtr) As LongPtr
    Private Declare PtrSafe Function ReleaseDC Lib "user32" (ByVal hWnd As LongPtr, ByVal hdc As LongPtr) As LongPtr
    Private Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hdc As LongPtr, ByVal nIndex As LongPtr) As LongPtr
    
    ' GetSystemMetrics() codes
    Private Declare PtrSafe Function apiGetSystemMetrics Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As LongPtr) As LongPtr
#Else '32-bit Office
    Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
    Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long) As Long
    Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
    
    ' GetSystemMetrics() codes
    Private Declare Function apiGetSystemMetrics Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
#End If
'###############################################

Private Const HWND_DESKTOP As Long = 0
Private Const LOGPIXELSX As Long = 88
Private Const LOGPIXELSY As Long = 90
    
Public Enum SystemConstants
    SM_CXSCREEN = 0
    SM_CYSCREEN = 1
    SM_CXVSCROLL = 2
    SM_CYHSCROLL = 3
    SM_CYCAPTION = 4
    SM_CXBORDER = 5
    SM_CYBORDER = 6
    SM_CXDLGFRAME = 7
    SM_CYDLGFRAME = 8
    SM_CYVTHUMB = 9
    SM_CXHTHUMB = 10
    SM_CXICON = 11
    SM_CYICON = 12
    SM_CXCURSOR = 13
    SM_CYCURSOR = 14
    SM_CYMENU = 15
    SM_CXFULLSCREEN = 16
    SM_CYFULLSCREEN = 17
    SM_CYKANJIWINDOW = 18
    SM_MOUSEPRESENT = 19
    SM_CYVSCROLL = 20
    SM_CXHSCROLL = 21
    SM_DEBUG = 22
    SM_SWAPBUTTON = 23
    SM_RESERVED1 = 24
    SM_RESERVED2 = 25
    SM_RESERVED3 = 26
    SM_RESERVED4 = 27
    SM_CXMIN = 28
    SM_CYMIN = 29
    SM_CXSIZE = 30
    SM_CYSIZE = 31
    SM_CXFRAME = 32
    SM_CYFRAME = 33
    SM_CXMINTRACK = 34
    SM_CYMINTRACK = 35
    SM_CXDOUBLECLK = 36
    SM_CYDOUBLECLK = 37
    SM_CXICONSPACING = 38
    SM_CYICONSPACING = 39
    SM_MENUDROPALIGNMENT = 40
    SM_PENWINDOWS = 41
    SM_DBCSENABLED = 42
    SM_CMOUSEBUTTONS = 43
    SM_CMETRICS = 44
    SM_CXSIZEFRAME = SM_CXFRAME
    SM_CYSIZEFRAME = SM_CYFRAME
    SM_CXFIXEDFRAME = SM_CXDLGFRAME
    SM_CYFIXEDFRAME = SM_CYDLGFRAME
    
    SM_TABLETPC = 86
End Enum

'this is do with the mdi client
'###############################################
'Add PtrSafe - required for 64-bit Office (VBA7)
#If VBA7 Then
    Private Declare PtrSafe Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    Private Declare PtrSafe Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    Private Declare PtrSafe Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
#ElseIf Win64 Then 'need datatype LongPtr
    Private Declare PtrSafe Function GetWindowRect Lib "user32" (ByVal hWnd As LongPtr, lpRect As RECT) As LongPtr
    Private Declare PtrSafe Function GetClientRect Lib "user32" (ByVal hWnd As LongPtr, lpRect As RECT) As LongPtr
    Private Declare PtrSafe Function GetParent Lib "user32" (ByVal hWnd As LongPtr) As LongPtr
#Else '32-bit Office
    Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
    Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
#End If
'###############################################

' Error handling
Dim ErrorSource As String

' Returns a size variable containing the width and height of the MDI Client area
'   for Microsoft Access at that moment in time.
' 
' ARGUMENTS
' InPixels      TRUE - return the size in pixels
'               FALSE (default) - return the size in twips
Public Function AccessAppInsideSize _
        (Optional InPixels As Boolean = False) _
         As Size
Dim rectMDIClient As RECT
Dim sizePixels As Size, sizeTwips As Size
Dim WidthInPixels As Long, HeightInPixels As Long
'
' Initialize error handling
On Error Resume Next ' if an error occurs this routine will return a size of 0,0
'
' Open a dummy form or use an existing form so we can grab the parent of its window handle (hWnd)
Dim F As New Form
Dim bCloseForm As Boolean
Dim bFoundNonPopUpForm As Boolean
If Forms.count > 0 Then
    ' Find non-PopUp form
    Dim frm As Access.Form
    For Each frm In Forms
        If Not frm.PopUp Then
            Set F = frm
            bCloseForm = False
            bFoundNonPopUpForm = True
            Exit For
        End If
    Next
End If
If Not bFoundNonPopUpForm Then
    Set F = CreateForm
    bCloseForm = True
End If
'
' Get the screen coordinates and window size of the rectMDIClient window
GetWindowRect GetParent(F.hWnd), rectMDIClient
' Close dummy form without saving
If bCloseForm Then DoCmd.Close acForm, F.Name, acSaveNo
'
' Calculate size in pixels
sizePixels.Width = rectMDIClient.right - rectMDIClient.Left - modMetrics.System(SM_CXFRAME, False)
sizePixels.Height = rectMDIClient.bottom - rectMDIClient.top - modMetrics.System(SM_CYFRAME, False)
'
' Return correct values
If InPixels Then
    ' return result as is
    AccessAppInsideSize = sizePixels
Else
    ' convert result to twips
    sizeTwips.Width = modMetrics.converttoTwipsX(sizePixels.Width)
    sizeTwips.Height = modMetrics.converttoTwipsY(sizePixels.Height)
    AccessAppInsideSize = sizeTwips
End If
End Function

' Converts twips to pixels
' 
Public Function converttoPixelX(ByVal TwipsX As Long) As Long
Dim lngDC As Long, intPerPixelX As Integer
lngDC = GetDC(HWND_DESKTOP)
intPerPixelX = 1440 / GetDeviceCaps(lngDC, LOGPIXELSX)
ReleaseDC HWND_DESKTOP, lngDC
converttoPixelX = TwipsX / intPerPixelX
End Function

' Converts pixels to twips
' 
'
Public Function converttoPixelY(ByVal TwipsY As Long) As Long
Dim lngDC As Long, intPerPixelY As Integer
lngDC = GetDC(HWND_DESKTOP)
intPerPixelY = 1440 / GetDeviceCaps(lngDC, LOGPIXELSY)
ReleaseDC HWND_DESKTOP, lngDC
converttoPixelY = TwipsY / intPerPixelY
End Function
                 
' Converts pixels to twips
' 
Public Function converttoTwipsX(ByVal PixelX As Long) As Long
Dim lngDC As Long, intPerPixelX As Integer
lngDC = GetDC(HWND_DESKTOP)
intPerPixelX = 1440 / GetDeviceCaps(lngDC, LOGPIXELSX)
ReleaseDC HWND_DESKTOP, lngDC
converttoTwipsX = intPerPixelX * PixelX
End Function

' Converts pixels to twips
' 
Public Function converttoTwipsY(ByVal PixelY As Long) As Long
Dim lngDC As Long, intPerPixelY As Integer
lngDC = GetDC(HWND_DESKTOP)
intPerPixelY = 1440 / GetDeviceCaps(lngDC, LOGPIXELSY)
ReleaseDC HWND_DESKTOP, lngDC
converttoTwipsY = intPerPixelY * PixelY
End Function

' Converts point size (from a font) to twips
' 
Public Function converttoTwipsYFromPoint(PointSize As Long) As Long
Dim lngDC As Long, intPerPixelY As Integer
lngDC = GetDC(HWND_DESKTOP)
intPerPixelY = 1440 / GetDeviceCaps(lngDC, LOGPIXELSY)
converttoTwipsYFromPoint = intPerPixelY * Int(PointSize * GetDeviceCaps(lngDC, LOGPIXELSY) / 72)
ReleaseDC HWND_DESKTOP, lngDC
End Function

' Returns the dimensions of the screen, in twips or pixels
' 
Public Function MetricsScreenHeight _
        (Optional ConvertToTwips As Boolean = True)
MetricsScreenHeight = System(SM_CYSCREEN, ConvertToTwips)
End Function
Public Function MetricsScreenWidth _
        (Optional ConvertToTwips As Boolean = True)
MetricsScreenWidth = System(SM_CXSCREEN, ConvertToTwips)
End Function

' Returns a result of GetSystemMetrics in twips or pixels
' 
Public Function System(SystemMetricRequired As SystemConstants, Optional ConvertToTwips As Boolean = True) As Variant
If ConvertToTwips Then
    Select Case SystemMetricRequired
        Case SM_CYSCREEN, SM_CYHSCROLL, SM_CYCAPTION, _
                SM_CYBORDER, SM_CXDLGFRAME, SM_CYDLGFRAME, _
                SM_CYVTHUMB, SM_CYICON, SM_CYCURSOR, _
                SM_CYMENU, SM_CYFULLSCREEN, SM_CYKANJIWINDOW, _
                SM_CYVSCROLL, SM_CYMIN, SM_CYSIZE, _
                SM_CYFRAME, SM_CYMINTRACK, SM_CYDOUBLECLK, _
                SM_CYICONSPACING, SM_CYSIZEFRAME, SM_CYFIXEDFRAME
            System = converttoTwipsY(apiGetSystemMetrics(SystemMetricRequired))
        Case Else: System = converttoTwipsX(apiGetSystemMetrics(SystemMetricRequired))
    End Select
Else
    System = apiGetSystemMetrics(SystemMetricRequired)
End If
End Function
 
Welcome to AWF. I moved your thread out of the introductions forum.
 
The onscreen keyboard does not have a pause/break key that I can see.

I cannot find Microsoft's answer to this problem that they have created.

Using a separate wireless keyboard get around the problem but it is not ideal.

I have tried Autokeys using the code

^B:: ;Ctrl + B
^CtrlFnBreak
return

Obviously the code is incorrect as I could not get this too work
 
Please read post #3 where I explained about how to deal with that
 
There is actually a solution. It is a cntl/shift/somekey combination --NO CODE required. I no longer have the computer with the problem keyboard (with the relevant sticky note posted to it) and I can't remember where I found the solution. I'll look later to see if I can find it again. Just knowing it is out there may be enough for you to be persistent in your google search.
 
Pat
As I've already said in post #3, the solution is Ctrl+ScrLk.
That's what I use for debugging on my MS keyboard which has no Break key
 

Users who are viewing this thread

Back
Top Bottom