Text box changes from code. What EVENT fires?

B

Bill

I have a text box that gets changed in code
following a select in a calendar sub-form.
What "Event" fires so I can call the "text-box"
On Click event code? I would have thought
the On Change would do the job, but no.
 
B

Bill

DUH! I know the OnChange doesn't fire unless
there's direct keyboard action. However, is there
a way to trigger an event from code?
 
J

John W. Vinson

DUH! I know the OnChange doesn't fire unless
there's direct keyboard action. However, is there
a way to trigger an event from code?

No form event will fire... but heck, you're running code already. Just call
the desired subroutine from the code you already are using.

Call txtMyTextbox_AfterUpdate()

for example.

Note that the Change event isn't often very useful - it doesn't fire when the
textbox's value has been changed (the AfterUpdate event is better for that),
but instead it fires at every user keystroke. This can be handy if you (say)
want to convert the user's entry to all caps, but that's about it.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
B

Bill

Hi John,
I've been playing with that idea already, but since
the tb contents is changed from within the code
sheet of a subform, I've not quite figured out how
to run code in the code sheet of the parent.
Bill
 
J

John W. Vinson

B

Bill

Call Parent.tbDate_AfterUpdate

When I attempt that, I get error 2465, "can't find the
field 'frmSermonSelect' referred to in your expression"

'frmSermonSelect' is the name of the parent form, so
I don't know why Access thinks it's a field name.

Bill
 
D

Douglas J Steele

Exactly what is the code you're trying to run?

When John said

Call Parent.txtControlname_AfterUpdate

he meant use the literal expression Parent. The only change you need to make
is to replace txtControlname with the actual name of the text box on the
parent form.

"Bill" wrote in message

Call Parent.tbDate_AfterUpdate

When I attempt that, I get error 2465, "can't find the
field 'frmSermonSelect' referred to in your expression"

'frmSermonSelect' is the name of the parent form, so
I don't know why Access thinks it's a field name.

Bill
 
B

Bill

Hi Doug,
It's like I posted. I attempt to run the Sub
tbDate_AfterUpdate in the "parent"
frmSermonSelect. But when that executes
I get the 2465 error that refers to the form
as though it's a "field". Again, the exact code
is: Call Parent.tbDate_AfterUpdate
Bill
 
M

Marshall Barton

Bill said:
It's like I posted. I attempt to run the Sub
tbDate_AfterUpdate in the "parent"
frmSermonSelect. But when that executes
I get the 2465 error that refers to the form
as though it's a "field". Again, the exact code
is: Call Parent.tbDate_AfterUpdate

When you use Call, you must use ()
Call Parent.tbDate_AfterUpdate()
Alternatively, if you do not use Call,
then don't use the ():
Parent.tbDate_AfterUpdate

Personally, I prefer the latter, but either should be ok.
 
B

Bill

The problem is that when I employed the use of a
pop-up calendar, that updates a text box with the
selected date, I failed to include the calendar form
as a sub-form to the main form. That being the case,
the calendar's VBA code sheet doesn't consider
the main form as "the parent".

In the course of scratching my head, what's left of
it, I found Allen's pop-up calendar that has more
functionality than what I've been using, so I'll
install his calendar "properly" after completing
some pressing Win7 and Office 2010 issues.

Thanks John, Doug & Marsh,
Bill
 

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

Top