[VBA, V8i ss3] Write a value to a form field

Hi!

I am experiencing problems when trying to write a value to a form field.

I have a form called "FormA", with some buttons and a text field "FieldA". I would like to update the content of this text field several places in my code. However, it seems like I can't get the syntax right.

I have tried the following variations:

Forms!FormA.FieldA = 123
Forms!FormA.FieldA.Value = 123
Forms![FormA].FieldA = 123
Forms![FormA].[FieldA] = 123
Forms![FormA].FieldA.Value = 123
Forms![FormA].[FieldA].Value = 123

... without succes. When compiling the code, I get no error.
When single-stepping through the code, the debugger stops when trying to execute the line - no error message attached.

Any help is appreciated.

Best regards,

Søren

Parents
  • Unknown said:
    Forms!FormA.FieldA = 123

    Forms is not a VBA keyword.  From VBA help...

    A UserForm object is a window or dialog box that makes up part of an application's user interface.

    The UserForms collection is a collection whose elements represent each loaded UserForm in an application. The UserForms collection has a Count property, an Item property, and an Add method. Count specifies the number of elements in the collection; Item (the default member) specifies a specific collection member; and Add places a new UserForm element in the collection.

    Syntax

    UserForm

    UserForms[.Item](index)

    The placeholder index represents an integer with a range from 0 to UserForms.Count – 1. Item is the default member of the UserForms collection and need not be specified

    Note that the UserForms collection applies to loaded UserForms.  If your form is not loaded, then it's not in that collection.

     
    Regards, Jon Summers
    LA Solutions

Reply
  • Unknown said:
    Forms!FormA.FieldA = 123

    Forms is not a VBA keyword.  From VBA help...

    A UserForm object is a window or dialog box that makes up part of an application's user interface.

    The UserForms collection is a collection whose elements represent each loaded UserForm in an application. The UserForms collection has a Count property, an Item property, and an Add method. Count specifies the number of elements in the collection; Item (the default member) specifies a specific collection member; and Add places a new UserForm element in the collection.

    Syntax

    UserForm

    UserForms[.Item](index)

    The placeholder index represents an integer with a range from 0 to UserForms.Count – 1. Item is the default member of the UserForms collection and need not be specified

    Note that the UserForms collection applies to loaded UserForms.  If your form is not loaded, then it's not in that collection.

     
    Regards, Jon Summers
    LA Solutions

Children
No Data