Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

really quick "subform ?" or, long "whats the best approach ?&quot 1

Status
Not open for further replies.

LikeThisName

Vendor
May 16, 2002
288
0
0
US
short question?
is it not possible to get value from a textbox in a bound subform?

MsgBox Me!mySubForm.Question produces: run-time error 438

what I want to do is make me.Question = Me!mySubForm.Question
if me.Question fails to meet certain criteria

i thought using a subform that was bound and linked would be quicker then opening up tables, but maybe that was foolish.

What are your thoughts?
 
i went ahead and opened a recordset and updated there then requeried

as far as my richtextbox subform i added that to main form but made invisible and used the open recordset to change the me.richtextbox1 then requeried the form and richtext subform. reason i have richtextbox in a subform in the first place was because of the editbar to format and load the text.

not urgent-
still interested in how to change or retrieve field values in subforms and your thoughts on approach. thanks!
 
'Important: Differentiate between a form, a subform, and a subform control
'The first two are forms; the third is a control which is placed on a form and
'points to another form.
'frmSub is NOT necessarily the name of the source subform. Rather it is the name of
'the control I placed on my form. Click on the subform border to select it.
'The property sheet should start Subform/SubReport if it has Form instead, you
'miss targetted and chose the form to which the control points. You know you
'have it when the resize handles appear around the subform control.

'In my case, I made both my Subform/Subreport.Name ="frmSub" and
'Subform/Subreport.SourceObject = "frmSub" to avoid conflict. But just so you know,
'The code below requires "frmSub" to be the Subform/Subreport.Name

'Also note you can nest up to seven times using:
' Forms("frmMain")("frmSub")("frmSub2")("frmSub3")...("txtField")

Option Compare Database
Option Explicit
Private Sub cmdSet_Click()
'Using complete syntax to set a field on a sub form
'Forms("frmMain").Controls("frmSub").Form.Controls("txtLName").Value = "YourName"

'Same thing but taking advantage of Access's default control properties
'Forms("frmMain")("frmSub")("txtLName") = "YourName"

'Same thing but but frmMain is current form so no need to reference
frmSub("txtLName") = "YourName"

End Sub
Private Sub cmdGet_Click()
Dim strLName As String
'Using complete syntax to get the value from a field on a subform
'strLName = Forms("frmMain").Controls("frmSub").Form.Controls("txtLName").Value

'Same thing but taking advantage of Access's default control properties
'strLName = Forms("frmMain")("frmSub")("txtLName")

'Same thing but but frmMain is current form so no need to reference
strLName = frmSub("txtLName")

MsgBox strLName
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top