How to reference a Form in an Event Proceedure ??

M

MyEmailList

What I have...

TestDB.mdb is my data base
tblTest is my table
frmCustomer is my form
fldText is a field on the form (may be bound to table data or unbound)

When the client moves to the next record (after they finish updating
the current record) I want my code to run...

Here is what I tried...

strTestText = "this is a test"
frmCustomer.fldTest = strTestText

but it didn't work.

I don't know how to properly reference the current form using the
"dot" reference system.

Thanks for any help.

Mel
 
J

John W. Vinson

What I have...

TestDB.mdb is my data base
tblTest is my table
frmCustomer is my form
fldText is a field on the form (may be bound to table data or unbound)

Minor correction. Tables have fields; Forms have Controls. The Textbox Control
named fldText may be bound to the table field named fldText; you may want to
consider using a naming convention that removes this ambiguity.
When the client moves to the next record (after they finish updating
the current record) I want my code to run...
Here is what I tried...

strTestText = "this is a test"
frmCustomer.fldTest = strTestText

but it didn't work.

Where did you put this code? What exactly are you trying to accomplish? Is
fldTest bound to some Table field? You can use the Form's BeforeUpdate event
(which fires when the user does something to save the record, such as moving
to the next or closing the form), or the AfterUpdate event which fires after
the record has been written to disk, depending on what you're trying to
accomplish.
I don't know how to properly reference the current form using the
"dot" reference system.

Forms!frmCustomer!fldTest

or you can use the shortcut notation

Me.fldTest

if the code is attached to the form.


John W. Vinson [MVP]
 
6

'69 Camaro

Hi, Mel.
I don't know how to properly reference the current form using the
"dot" reference system.

There are several ways. One of the easiest is to use the "Me" keyword to
reference the current form. Also, the Forms Collection can be referenced,
whether or not the current form or another form is named. Examples:

Me!fldText.Value = "this is a test"
Forms!frmCustomer!fldText.Value = "this is a test"
Forms!frmCustomer.fldText.Value = "this is a test"
Forms("frmCustomer").fldText.Value = "this is a test"

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
Top