open a subform when a name is entered on mainform, please!!

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

Guest

Hi, please help me with this. When i am in the mainform and i select a
name(Table-eName) from a combo box and (either a button click or after i
selected name). i want a subform that would load the information from another
table(Table-wName). and on this subform i want only to show those file that
is related to the name that is selected on the mainform. And in both table
has the name filed. Also, I want that subform to be editable directly. (Ex.
If I want to change his hours(one of the filed on Table-wName) of the
subform. It has to be updated on the Table-wName.) I am unable to make the
subform to retrieve the information of the name that I selected on the
mainform. Please help me with this and if I need any vb-code please give me.
Thanks!
 
Thelee,

All you need is an unbound combo box to select a name, code in the
AfterUpdate event procedure to goto that main form record, and set your
subform's LinkMasterFields and LinkChildFields properties to the name of the
main form's record source's primary key, and the corresponding foreign key in
the subform's record source, respectively.

Once the code navigates to the correct main form record, the detail
associated with it will display in the subform because of the link properties
you've defined. Something like, in the AfterUpdate event of your unbound
combo box:

Dim strCriteria As String
DoCmd.OpenForm "YourFormName", acNormal, , "[YourPrimaryKeyField]= " &
Me!YourComboBox

Hope that helps.
Sprinks
 
Hi Sprinks, Thanks! it is working now.

If you don’t mind, I have another problem,too. In the MainForm I select a
name(Table-name) and a subform that retrieve information from Table-Project.
There is a filed name Period (number 1-12). Now I made the subform to retrive
information for only Period (1). I want to create subform to display each of
the Period individually. Table-Project has name,period filed and each row may
be repeated none of them is primary keys. (ex. Using Tab Control, having
twelve tab and each have each period on). And it should be able to display
only those row with Period. I know we could do this but how I don’t know. We
could use tab or anything. I just want them to be displaced in order. And One
More, each subform has another filed Percentage. And under each tab I want
that text box to display total Percentag and if the Percentage is above 100%,
it should display a error msg. I know we could do this, but I am new to this.
Please help me with this,too. Thanks!

Sprinks said:
Thelee,

All you need is an unbound combo box to select a name, code in the
AfterUpdate event procedure to goto that main form record, and set your
subform's LinkMasterFields and LinkChildFields properties to the name of the
main form's record source's primary key, and the corresponding foreign key in
the subform's record source, respectively.

Once the code navigates to the correct main form record, the detail
associated with it will display in the subform because of the link properties
you've defined. Something like, in the AfterUpdate event of your unbound
combo box:

Dim strCriteria As String
DoCmd.OpenForm "YourFormName", acNormal, , "[YourPrimaryKeyField]= " &
Me!YourComboBox

Hope that helps.
Sprinks

Thelee said:
Hi, please help me with this. When i am in the mainform and i select a
name(Table-eName) from a combo box and (either a button click or after i
selected name). i want a subform that would load the information from another
table(Table-wName). and on this subform i want only to show those file that
is related to the name that is selected on the mainform. And in both table
has the name filed. Also, I want that subform to be editable directly. (Ex.
If I want to change his hours(one of the filed on Table-wName) of the
subform. It has to be updated on the Table-wName.) I am unable to make the
subform to retrieve the information of the name that I selected on the
mainform. Please help me with this and if I need any vb-code please give me.
Thanks!
 
Back
Top