Form data to automatically upldate a field in the subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form and an invisible subform attached to the form. I want that
after update of the student first name the status id field of the subform
should be filled in as No Status Given. How can this be done - is it an event
procedure if so what is the code

Please can someone help i've been trying to work this out for some time.
 
One way to do this when the subform control is not visible is to update the
value, then requery the subform control. Try:

Private Sub txtFName_AfterUpdate()

On Error GoTo ErrHandler

Me!MyCtrl.Form.txtStatusID.Value = "No Status Given"
Me!MyCtrl.Requery

Exit Sub

ErrHandler:

MsgBox "Error in txtFName_AfterUpdate( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub

.. . . where txtFName is the name of the text box displaying the student's
first name, MyCtrl is the name of the subform control, and txtStatusID is the
name of the text box on the subform to be updated.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
I’m at work now and my database is at home so can I just clarify this with you:

txtFname is the text box displaying student first name so I will replace it
with StudentFirstName

MyCtrl is the name of the subform control so that is
E-Subform_for_registration
_form

txtStatusId is the name of the text box on the subform to be updated so I
will replace it with StatusID

Private Sub StudentFirstName_AfterUpdate()

On Error GoTo ErrHandler

Me! E-Subform_for_registration
_form.Form.StatusID.Value = "No Status Given"
Me! E-Subform_for_registration
_form.Requery

Exit Sub

ErrHandler:

MsgBox "Error in StudentFirstName _AfterUpdate( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub

Have i correctly substitued the terms?
Thanks for your help!!
 
Have i correctly substitued the terms?

It appears that the newsreader has broken up the name of your subform
control. If this isn't the case, then the name should be all one word,
without any spaces:

E-Subform_for_registration_form

It also appears that:

Me! E-Subform_for_registration_form

.. . . has a space between the exclamation point and the first letter of the
control's name. There should be no space.

A few words of advice: name your subform control differently than the name
of the subform, so that there's never any confusion whether the syntax should
apply to the subform control or to the subform. Also, to prevent bugs, only
use alphanumeric characters and the underscore in names. And you may want to
shorten the name E-Subform_for_registration_form to make the code more
maintainable.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
I think i dont understand what's the difference between the subform and the
subform control?
 
I think i dont understand what's the difference between the subform and the
subform control?

A subform is a form, just like any other form. It can be bound to a data
source, hold controls, and have its own form properties and a VBA module.

A subform control is a control (much like a text box, combo box, or buttons
are controls), but it's a special control that can hold another form's
properties and controls. When the main form is open, it's a member of the
Forms Collection, but the subform _isn't_ -- it's being "held" in a control
(called the subform control) on the main form, so it doesn't exist as an
instance of a separate form.

A subform control has a Form Property, and many of a regular form's
properties and methods can be used to manipulate the subform's properties and
its controls with this Form Property.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
bret
Database User said:
I'm at work now and my database is at home so can I just clarify this with you:

txtFname is the text box displaying student first name so I will replace it
with StudentFirstName

MyCtrl is the name of the subform control so that is
E-Subform_for_registration
_form

txtStatusId is the name of the text box on the subform to be updated so I
will replace it with StatusID

Private Sub StudentFirstName_AfterUpdate()

On Error GoTo ErrHandler

Me! E-Subform_for_registration
_form.Form.StatusID.Value = "No Status Given"
Me! E-Subform_for_registration
_form.Requery

Exit Sub

ErrHandler:

MsgBox "Error in StudentFirstName _AfterUpdate( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear

End Sub

Have i correctly substitued the terms?
Thanks for your help!!
time.
 
Back
Top