Change control in dialog form

R

RobGMiller

Using Access 2003.

Using VBA to change the content of a text control on a dialog form. (The
form is opened from another form using doCmd.FormOpen ,,,,, acDialog)

The value of the control will change from the form Open by simply using
ControlName = "New text" or Me.ControlName.Value = "New text"

This does not work from a function located in the form vba code.
 
D

Douglas J. Steele

Are you always wanting to set the value of the same control on the dialog
form?

Open the form using:

DoCmd.OpenForm "NameOfForm", acNormal, , , , acDialog, "SomeValue"

then in the Load event of the form, use

Private Sub Form_Load()

If IsNull(Me.OpenArgs) = False Then
Me!SomeTextbox = Me.OpenArgs
End If

End Sub

If you're trying to have the dialog form refer to a value on the form that's
opening it, you can simply use

Private Sub Form_Load()

Me!SomeTextbox = Forms!NameOfOtherForm!NameofControl

End Sub
 

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