Change control in dialog form

  • Thread starter Thread starter RobGMiller
  • Start date Start date
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.
 
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
 
Back
Top