Using Forms 2.0 Frame Control on MS Access Form

Please provide a VBA example of how to access and set the value of a textbox placed on an MS Forms 2.0 Frame Control within an MS Access form.

In Excel the following code displays the value of textbox1:

MsgBox Frame1.Controls("textbox1").Text

On an Access form, this does not work  

In addition:

Frame1.Controls.Count = 0

 
LVL 3
jakemdrewAsked:
Who is Participating?
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Connect With a Mentor Infotrakker SoftwareCommented:
You generally must reference the Object property of the control. Many find it easier to set the control to a variable, so you can use Intellisense:

Dim ctl As forms.Frame
Set ctl = Me.YourFrameControl.Object

ctl.Controls("textbox1")

I'm not sure about the "forms.frame" ... I don't use the 2.0 controls due to the instability they seem to always produce, but I'm sure you can locate the correct library.

Note you do NOT reference the .Text property of Access textboxes unless those controls have the focus. This is unlike VB, where you must reference the .Text properly.
0
 
jakemdrewAuthor Commented:
This worked!  Thank you!

Dim x As MSForms.Frame

Set x = Me.Frame4.Object

MsgBox x.Controls("textbox1").Value
0
All Courses

From novice to tech pro — start learning today.