J
Joe S Slow
I have built a search form that has an unbound text field and a command
button. When the command button is pressed whatever is in the unbound text
field is used by the query to search by.
The thing I thought would be neat would be to have the query run as soon as
I hit the Enter key instead of clicking the Search button.
I have programmed it in the text field on the event 'On Key Down' with the
following code:
If KeyCode = vbKeyReturn Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
'KeyCode = 0 'Do this to prevent the
default action for the key
End If
The problem is that as soon as I hit the Enter key the query that runs looks
up the search text field but unfortunately it doesn't see anything in the
field. Usually when I click on the submit button I guess whatever I typed in
the search txt field is 'registered' so when the query by form looks up the
field something actually exists. With my 'On Key Down' event it looks like
this field was not entered and terminated prematurely so when the query
looks up the table it doesn't find anything.
Is there any command that I can issue so that whatever I typed prior to
hitting the Enter key is registered so when the query by form happens that
the field will be been populated.
Thanks!
button. When the command button is pressed whatever is in the unbound text
field is used by the query to search by.
The thing I thought would be neat would be to have the query run as soon as
I hit the Enter key instead of clicking the Search button.
I have programmed it in the text field on the event 'On Key Down' with the
following code:
If KeyCode = vbKeyReturn Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
'KeyCode = 0 'Do this to prevent the
default action for the key
End If
The problem is that as soon as I hit the Enter key the query that runs looks
up the search text field but unfortunately it doesn't see anything in the
field. Usually when I click on the submit button I guess whatever I typed in
the search txt field is 'registered' so when the query by form looks up the
field something actually exists. With my 'On Key Down' event it looks like
this field was not entered and terminated prematurely so when the query
looks up the table it doesn't find anything.
Is there any command that I can issue so that whatever I typed prior to
hitting the Enter key is registered so when the query by form happens that
the field will be been populated.
Thanks!