Pop-up dialog box - Return value on KeyPress

  • Thread starter Thread starter Santa-D
  • Start date Start date
S

Santa-D

I'm hoping someone can help.

I have a form with all the information related to leasing a motor
vehicle, in this form I have a subform which allows the user to make
comments which automatically inserts the date.
When dealing with vehicle acquisitions I've made a pop-up form which
comes up when the user hits the F4 key.

The form that comes up is "Common Messages" which includes a subform
with various comments i.e. VAA - Received from Supplier | VAA - Sent to
Region.

What I want to do is when the user presses the escape key, the form
closes and doesn't return a value (Which isn't working) and when they
press the enter key on a selected comment it returns the value to the
form. I just tried to use a macro that I'm using when you double click
on the record you want to insert into the comments form but it's on
every key press not just "Enter"

This is what I have so far.

<b>COMMENTS FORM</b>

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF4 Then
DoCmd.OpenForm ("frm-defaultmessages")
End If
End Sub

This works well. The defaultmessages form opens up showing a
subform-datasheet with various messages that can be entered or you can
type in a new one. Once the required value is selected I want to be
able to press the enter key and return the message selected to the Main
form.

The macro that I'm using when I double click on the record is simply
this.

<b>Set Value</>
- Item: [Forms]![qry-vehicle-search mainform]![db-vehicle-comments
subform].[Form]![Comments]
- Expression:
[Forms]![frm-defaultmessages]![tbl-common-messages_subform].[Form]![Message]

<b>Close</b>

What do I need to do to have the Enter key to return the value?

Would it be something like - vbKeyExecute?
 
You could display the text in a listbox..

I explain how you can pop up a form, and return values from that form here:

http://www.members.shaw.ca/AlbertKallal/Dialog/Index.html

So, set the close/cancel button on the form to "cancel"...(this means that
the button will be fired when ESC it hit).

Set the "ok" button = "default"...(this means that the button will be fired
when Enter key is hit).

The code can then example what value in the listbox is currently
selected....
 
If looked at that article...it talks about enhanced abilities in a97......

You can/would use the keydown event.......

However, as my other post points out...you don't even need to do that.......
 
Back
Top