TextBox Event

  • Thread starter Thread starter JPCAccess
  • Start date Start date
J

JPCAccess

On my form I have placed an event in the before update event which will
populate a text box on the form conditionally depending on which choice
is made. This works.

I have placed a command button on the form with an onClick event that
first refreshes the form data and then opens another form which matches
the record being created.

I want to place this sequence in an event property of the text box
first mentioned above so that when this text box populates, the
sequence refresh from data and open form happens automatically.

Can anyone tell me which event to place this in? I cannot seem to get
it to work. Thank you.
 
Instead of using an event of the text box out the code to open the second
form in the same BeforeUpdate event procedure as the code which assigns a
value to the text box. Either copy and paste the code from the button's
event procedure after the existing code in the BeforeUpdate event procedure,
or if you are intending to keep the button as well, call the button's Click
event procedure in the BeforeUpdate event procedure. This will save you
having to duplicate the code.

Ken Sheridan
Stafford, England
 
I have tried that but the form pops open before the value being placed
in the text box gets there. Any idea on how to make it work right?
Thank you very much.
 
Are you sure the code is in the correct order? If so you could insert a
DoEvents line to return control to the OS temporarily before opening the
second form, and/or insert a timed loop in the code. However, you shouldn't
have to refer to the text box itself to open the second form; use the value
itself instead, e.g. assuming it’s a text value you are placing into the
control:

Dim strMyValue As String, strCritera As String

If <condtion expression> Then
strMyVlaue = "ABC"
Else
strMyVlue = "XYZ"
EndIf

strCriteria = "MyField = """ & strMyValue & """"

Me.txtMyTextBox = strMyValue
DoCmd.OpenForm "MySecondForm", WhereCondition:= strCriteria

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top