Text Field

  • Thread starter Thread starter Jasper Recto
  • Start date Start date
J

Jasper Recto

I have a form that has a text field. That field asks for a certain letter.
When you type the letter in, you press a button that assigns that text field
to a value and then executes a command.

The problem I'm having is that if you just type the letter and then press
the button, it does not recognize the letter that was just inputted. It's
as if no letter was ever entered.

If you type the letter, hit return or tab to the next object and then press
the button, it accepts the input.

How can I get it to accept the input without having to hit enter after you
type in the input?

One thing that is different about this form is that I am not using a normal
button that access creates. I am using an image that runs the event
procedure when you click on it. Could that be the issue? If so, what can I
do?

Thanks,
Jasper
 
Jasper Recto said:
I have a form that has a text field. That field asks for a certain
letter. When you type the letter in, you press a button that assigns
that text field to a value and then executes a command.

The problem I'm having is that if you just type the letter and then
press the button, it does not recognize the letter that was just
inputted. It's as if no letter was ever entered.

If you type the letter, hit return or tab to the next object and then
press the button, it accepts the input.

How can I get it to accept the input without having to hit enter
after you type in the input?

One thing that is different about this form is that I am not using a
normal button that access creates. I am using an image that runs the
event procedure when you click on it. Could that be the issue? If
so, what can I do?

Yes, that's probably the issue. Since an image cannot receive the
focus, the focus stays on the text box, and thus the control's value
isn't updated.

One possibility is to use the text box's Text property in your code,
instead of the (default) Value property. But you have to be careful,
because you can only refer to a control's Text property when the control
has the focus. Just in case, you might check to see if the text box has
the focus or not, and use either the Text or the Value property as
appropriate. For example:

Dim strEntry As String

With Me!txtTheTextBox
If .Name = Me.ActiveControl.Name Then
strEntry = .Text
Else
strEntry = .Value
End If
End With
 
Dirk,

Can you clarify the code you wrote below.

Dim strEntry As String

With Me!txtTheTextBox
If .Name = Me.ActiveControl.Name Then
strEntry = .Text
Else
strEntry = .Value
End If
End With

The "Me!txtTheTextBox" - I'm assuming that's the textbox in question. So if
it's 'Text3' then that statement should be? "Me!txtText3"

This statement:
.Name = Me.ActiveControl.Name
What is the '.Name = '? Am I supposed to leave it as is or should that be a
variable?

This statement:
strEntry = .Text
Else
strEntry = .Value
Is strEntry the value I'm supposed to use? What is the '.Text' and '.Value'
supposed to be? Am I supposed to change that?

Finally, where do place this. Currently, all I have is this statement:
myvalue2 = text3
Is this statement supposed to replace that?

Thanks !!!

Jasper
 
Forget it! I figured it out.

Thanks,
Jasper
Jasper Recto said:
Dirk,

Can you clarify the code you wrote below.

Dim strEntry As String

With Me!txtTheTextBox
If .Name = Me.ActiveControl.Name Then
strEntry = .Text
Else
strEntry = .Value
End If
End With

The "Me!txtTheTextBox" - I'm assuming that's the textbox in question. So if
it's 'Text3' then that statement should be? "Me!txtText3"

This statement:
.Name = Me.ActiveControl.Name
What is the '.Name = '? Am I supposed to leave it as is or should that be a
variable?

This statement:
strEntry = .Text
Else
strEntry = .Value
Is strEntry the value I'm supposed to use? What is the '.Text' and '.Value'
supposed to be? Am I supposed to change that?

Finally, where do place this. Currently, all I have is this statement:
myvalue2 = text3
Is this statement supposed to replace that?

Thanks !!!

Jasper
 
Jasper Recto said:
Dirk,

Can you clarify the code you wrote below.

Dim strEntry As String

With Me!txtTheTextBox
If .Name = Me.ActiveControl.Name Then
strEntry = .Text
Else
strEntry = .Value
End If
End With

The "Me!txtTheTextBox" - I'm assuming that's the textbox in question.
So if it's 'Text3' then that statement should be? "Me!txtText3"
Me!Text3

This statement:
.Name = Me.ActiveControl.Name
What is the '.Name = '? Am I supposed to leave it as is or should
that be a variable?

Leave it as it is. The statement compares the Name property of the text
box with the Name property of the form's active control. If they are
the same, then the text box has the focus. If they are different, the
text box does not have the focus.
This statement:
strEntry = .Text
Else
strEntry = .Value
Is strEntry the value I'm supposed to use? What is the '.Text' and
'.Value' supposed to be? Am I supposed to change that?

Don't change any of that. strEntry is a variable that we defined to
hold the letter that the user typed in the control. The idea is that we
get that letter from either the control's Text property or its Value
property -- the If statement decides which -- and hold it in strEntry
for further use. That way, the code that follows can examine the value
of strEntry, and not have to go into any conditional logic of its own.
Finally, where do place this. Currently, all I have is this
statement: myvalue2 = text3
Is this statement supposed to replace that?

I can't say, because you haven't shown me your code. All I know is that
you have code in the Click event of an image, that currently refers to
the text box Text3. This code would go into that event procedure, and
then you would replace at least one subsequent reference to Text3 with
strEntry. You might replace
myvalue2 = text3

with

myvalue2 = strEntry

or else you might possibly use strEntry in place of myvalue2 in the
subsequent code. I can't say, because I haven't seen the code. I'm not
clairvoyant.
 
Thanks!!
Jasper
Dirk Goldgar said:
Leave it as it is. The statement compares the Name property of the text
box with the Name property of the form's active control. If they are
the same, then the text box has the focus. If they are different, the
text box does not have the focus.


Don't change any of that. strEntry is a variable that we defined to
hold the letter that the user typed in the control. The idea is that we
get that letter from either the control's Text property or its Value
property -- the If statement decides which -- and hold it in strEntry
for further use. That way, the code that follows can examine the value
of strEntry, and not have to go into any conditional logic of its own.


I can't say, because you haven't shown me your code. All I know is that
you have code in the Click event of an image, that currently refers to
the text box Text3. This code would go into that event procedure, and
then you would replace at least one subsequent reference to Text3 with
strEntry. You might replace


with

myvalue2 = strEntry

or else you might possibly use strEntry in place of myvalue2 in the
subsequent code. I can't say, because I haven't seen the code. I'm not
clairvoyant.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top