Calling a subform from button on main form

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

Guest

Hi all,
I have a main form "student" and I want to call a subform "registration"
from that form via a button on the form. Right now I can get the button to
filter the results to show only the entries in "registration" for that
student, but I cannot add another entry in "registration" and have it
correspond to that student. Can anyone help me figure out how to call this
subform without imbedding it in the main form? Thank you!
 
Hi Lisa

This is not a true subform, but let's call it a "consequent" form.

With a true subform, you have LinkMasterFields and LinkChildFields
properties which serve two purposes: they automatically filter the view of
the subform, limiting it to a particular value in a particular field (or
fileds), and they also automatically set the default value for that field
(or fields) to the link value.

With a consequent form, you need to look after that stuff manually.

Already you have done the first part - setting up the filter. For the
default value, I suggest you pass the StudentID via the OpenArgs property.
For example:

DoCmd.OpenForm "frmRegistration", _
WhereCondition := "[StudentID]=" & Me.StudentID, _
WindowMode := acDialog, _
OpenArgs := StudentID

Now, in the Form_Load event proc of you registration form, check OpenArgs
and set the DefaultValue property:

If Not IsNull(Me.OpenArgs) Then
Me.[YourStudentField].DefaultValue = """" & Me.OpenArgs & """"
End If
 

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

Back
Top