Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Repost: Form/on open 2

Status
Not open for further replies.

rhonda11

Technical User
Nov 4, 2002
96
US
I have a form called Update Existing Projecst, that will only allow addition, no Data entry or Deletion. This form has a drop down combox that allow the user to pull the specific record to be update. My problem is that everytime I first open the form, it default to the very first record with the information appear as if this this was selected to be update. And to top it off, the combox for lookup the specific record was not even selected (blank). How can I have this form as a blank form until the user select a particular project Id from the combo box, then the information shall appeared.Any suggestion guys.

Hope it's clearer this time. My other question is to disable the find command from the keyboard (CTRL + F).
I would like the user to use the combo box as the main nav to find the specific record only.

Thanks again
 
Use an unbound form & write the record entered on the form to the table via code.

Regards
Warwick
 
Thanks for the your reply, but I really am lost with your suggestion. Kind of new at this, if you can detailed your suggesttion that would be appreciated. Thanks for your help.
 
This is the only solution I've been able to come up with, with regard to disabling Ctrl-F. It's long-winded, but it works. Access won't allow me to control the keydown and keyup events via the Form. Unless I've got a dud version of Access!

Copy and paste the following into a global module:

Global gControlKeyPressed As Boolean

Public Function ControlKeyDown(K_Code As Integer)
If K_Code = vbKeyControl Then
gControlKeyPressed = True
End If
If gControlKeyPressed = True Then
If K_Code = vbKeyF Then
DoCmd.CancelEvent
End If
End If
End Function

Public Function ControlKeyUp(K_Code As Integer)
If K_Code = vbKeyControl Then
gControlKeyPressed = False
End If
End Function
----------------------------------------------------------

Into all, yes all controls that can recieve the focus paste this into their keydown event:

ControlKeyDown (KeyCode)
----------------------------------------------------------

Into their keyup event:

ControlKeyUp (KeyCode)

----------------------------------------------------------

In a VB form you would only have to do this once. Why not Access????

Maybe, before doing this, wait and see if someone can come up with a better solution.

Regards

Bill
 
Note to Bill:

Access won't allow me to control the keydown and keyup events via the Form.

You probably aren't setting the form's Key Preview property to Yes. If you don't do that, the focused control gets the first shot at handling the keystroke.

Also, in your form's KeyDown event, you have to change the KeyCode parameter to 0 to prevent it from being further handled by the focused control and, later, by Access. That is, set KeyCode to 0 before exiting Form_KeyDown in order to "eat" the keystroke. Rick Sprague
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Dear Rick,

Thankyou, Thankyou for that one.

In all the years I have been programming Access, what an embarassment, I have never investigated what Key Preview did.

Definitely, owe you a pint or two, definitely a star.

Bill Power
 
Hi rhonda11,

Here is a replacement to my procedure above, to stop user's using Ctrl+F and Ctrl+H.

As Rick pointed out, cheers again Rick, set your form's Key Preview to Yes. Paste the following into a global module:

Global gControlKeyPressed As Boolean
Global gCancelKeyPress As Boolean

Public Function ControlKeyDown(K_Code As Integer)
If K_Code = vbKeyControl Then
gControlKeyPressed = True
End If
If gControlKeyPressed = True Then
Select Case K_Code
Case vbKeyF 'Find
gCancelKeyPress = True
Case vbKeyH 'Replace
gCancelKeyPress = True
Case Else
gCancelKeyPress = False
End Select
End If
End Function

Public Function ControlKeyUp(K_Code As Integer)
If K_Code = vbKeyControl Then
gControlKeyPressed = False
End If
End Function
-----------------------------------------------------------

Paste the following into the form's key down event:

ControlKeyDown (KeyCode)
If gCancelKeyPress = True Then
KeyCode = 0
gCancelKeyPress = False
End If
-----------------------------------------------------------

Paste the following into the form's key upevent:

ControlKeyUp (KeyCode)
-----------------------------------------------------------

You can modify this procedure to trap for any other Ctrl+keys or copy and re-write it as another procedure to e.g. stop the use of specified Function Keys or Alt+keys.

Bill







 
Hey Bill and Rick, thanks a lot for your help. But Bill, I'm new on Access, especially on the event procedures. I mean I know how to get into the event procedure, but don't how to create the global module from access. I did it before in VB, Access is a little bit different. Can you show me how get into the global module. You also mentioned that I have to paste on each control, at which event on each control? Thanks again for your help.
 
Hi Bill, I did it at the global module. The Ctrl+ F key is disable. Yehhhh!!........thank you so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top