PDA

View Full Version : hotkey for access form



Trevor
03-12-2008, 12:24 PM
I'm trying to assign hotkeys( ctrl +M) on a form to minimze the for when pressed, Im stuck, so far on my forms onkeypress event I have
Docmd.Minimze forms("<Formname>).onkey press = (^m)
but I'm missing the assignment to cause that event
my first error is on .minimize,
Does anyone have any ideas?

Carl A
03-12-2008, 03:00 PM
Might try this

Private Sub Form_Load()
'Form receives the keystroke first
Me.KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'checks to see if m is capitalized
If KeyCode = vbKeyM And Shift = 1 Then
DoCmd.Minimize
End If
End Sub

Trevor
03-12-2008, 08:41 PM
that works but I would like to use control + m instad of shift+m.
I have tried changing shift = 1 to Control = 1 but didnt work so i tried ctrl = 1 and that didn't work
and sugestions.
thanx for your prompt reply, and help

Trevor
03-12-2008, 08:43 PM
reason for control instead of shif is the users will be entering text , and if they want to enter a capital M, you can see my problem with that :-p

Carl A
03-13-2008, 08:30 AM
Your right my bad::yes

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim intCtrlDown As Integer

intCtrlDown = (Shift And acCtrlMask) > 0

If intCtrlDown And KeyCode = vbKeyM Then
DoCmd.Minimize
End If
End Sub

Trevor
03-13-2008, 11:29 PM
thanx that works but because I have an anel person who hates to use mice, I would like to use the same keycombo to maximize if it is mimized, I tried with out add any more decloration(its late) using
[code]
intCtrlDown = (Shift And acCtrlMask) > 0

If intCtrlDown And KeyCode = vbKeyM Then
DoCmd.Minimize
If .Minimize = True AndintCtrlDown and keyCode = vbKeyM Then
DoCmd.Maximze
End If: End If
End Sub
[Code\]
End If
and it wasn't happy with my .minimize
Yes I know that .Minimize would be a clash proporty how its writen
I figured might as well give it a shot since its already minimized, and there isn't a form proporty I can find that minimizes.

Carl A
03-14-2008, 08:39 AM
In the forms properties set the tag to 1

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim intCtrlDown As Integer

intCtrlDown = (Shift And acCtrlMask) > 0

' Display message telling user which key was pressed.
If Me.Tag = 2 Then
If intCtrlDown And KeyCode = vbKeyM Then
DoCmd.Maximize
Me.Tag = 1
Exit Sub
End If
End If

If Me.Tag = 1 Then
If intCtrlDown And KeyCode = vbKeyM Then
DoCmd.Minimize
Me.Tag = 2
End If

End If
End Sub

Trevor
03-14-2008, 10:49 AM
sorry I keep comming back with alternate questions but , because I'll be using a form for to display tables to be edited, how would I do the same for the mouse to prevent cut/copy with mouse, and to also trap left click + letter to also prevent, and keyboard shortcuts for you have coverd.

Carl A
03-14-2008, 01:00 PM
I'll be using a form for to display tables to be edited, how would I do the same for the mouse to prevent cut/copy with mouse,
I not sure why you would want to disable cut/copy with the mouse if you are editing records. But if you must just set the Shortcut Menu to No in the forms properties. But wouldn't you also want to disable those in the Edit Menu?


also trap left click + letter to also prevent, and keyboard shortcuts for you have coverd.
I'm not grasping just exactly what it is you want here.

Trevor
03-14-2008, 02:08 PM
I plan to use code in the kb to make acess look like a stand alone app.
and the reason for diabling cut/past when editing records is to foce users to my form to make reports; i dont want them to be able to bypass that form
fyi repots are outputed in .xls

Carl A
03-14-2008, 02:47 PM
the reason for diabling cut/past when editing records is to foce users to my form to make reports; i dont want them to be able to bypass that form
fyi repots are outputed in .xls
Are they allowed to edit? Your saying editing records but then they are just going to use the form to make reports.

If you don't want them changing the records then in the forms properties set

Allow Edits to no
Allow Additions to no
Allow Deletions to no

or in the forms load

Me.AllowAdditions = False
Me.AllowDeletions = False
Me.AllowEdits = False

Trevor
03-14-2008, 02:58 PM
I'm alloing them to make changes, ie: data incorrect.
wile making it as difficult as possable to manualy move or copy records to a different format

Carl A
03-17-2008, 03:20 PM
This will prevent selection of text

Private Sub Text0_KeyUp(KeyCode As Integer, Shift As Integer)
'Disable Shift and Arrow Keys
Text0.SelLength = 0
End Sub

Private Sub Text0_Mouseup(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
'Disable selecting with mouse
Text0.SelLength = 0
End Sub

Private Sub Text0_Enter()
'Will unselect text when tabing to a field
Text0.SelLength = 0
End Sub

Trevor
03-17-2008, 04:43 PM
I discoverd that from the previous post about minimize/maximize, that one the form is minimized it looses focus and the command to maximize won't work, but will work if focus to the form is set, witch I don't think is possable to have focus set to the mimized form is possable since the idea of mimizing is to move the form out of the way so the end user can do other work.

Trevor
03-19-2008, 01:55 PM
I am trying to use keydown enter this time and am having trouble:
on form keypreview = yes
the keydown event is on textbox

Dim IntEnterDown As Integer
IntEnterDown = (Shift And acEnterMask) > 0
If IntEnterDown Then Call OKButton

and its not working, I saw somthing that just said on msn's site Enter is default behavior