Sub Form In Datasheet View

G

Guest

I have a form that contains a sub form that is viewed as a datasheet. They
are linked by a single integer field (master/child). I want be able to get
information from the record in the sub form when the user clicks in one of
the text boxes within that record's line in the datasheet. So can I use some
tool or code to find out which record the user has selected?

Thanks for your help!
 
G

Guest

Do you want to refer to that value from the main form?
You can try
Me.[SubFormControlName].Form![TextBoxName]

Or to refer to a text box from a query or out side the form
Forms![MainFormName]![SubFormControlName].Form![TextBoxName]

You can use that also from the main form
 
G

Guest

Thanks for your help. When I use this type of lingo in the code I get the
information for the first record in the datasheet. That is fine when that is
the selected row but when there is more than one record and the user selects
the third row for instance how do I get the data from that row/record?

Thanks!

Ofer Cohen said:
Do you want to refer to that value from the main form?
You can try
Me.[SubFormControlName].Form![TextBoxName]

Or to refer to a text box from a query or out side the form
Forms![MainFormName]![SubFormControlName].Form![TextBoxName]

You can use that also from the main form

--
Good Luck
BS"D


mcgj said:
I have a form that contains a sub form that is viewed as a datasheet. They
are linked by a single integer field (master/child). I want be able to get
information from the record in the sub form when the user clicks in one of
the text boxes within that record's line in the datasheet. So can I use some
tool or code to find out which record the user has selected?

Thanks for your help!
 
G

Guest

You can use the OnCurrent event of the SubForm to assign the value to the
text box in the main form

Me.Parent.[TextBoxNameInMainForm] = Me.[TextBoxNameInSubForm]

That way this event will be triggered everytime you move a record

--
Good Luck
BS"D


mcgj said:
Thanks for your help. When I use this type of lingo in the code I get the
information for the first record in the datasheet. That is fine when that is
the selected row but when there is more than one record and the user selects
the third row for instance how do I get the data from that row/record?

Thanks!

Ofer Cohen said:
Do you want to refer to that value from the main form?
You can try
Me.[SubFormControlName].Form![TextBoxName]

Or to refer to a text box from a query or out side the form
Forms![MainFormName]![SubFormControlName].Form![TextBoxName]

You can use that also from the main form

--
Good Luck
BS"D


mcgj said:
I have a form that contains a sub form that is viewed as a datasheet. They
are linked by a single integer field (master/child). I want be able to get
information from the record in the sub form when the user clicks in one of
the text boxes within that record's line in the datasheet. So can I use some
tool or code to find out which record the user has selected?

Thanks for your help!
 
G

Guest

That did Ofer. Thanks!

Ofer Cohen said:
You can use the OnCurrent event of the SubForm to assign the value to the
text box in the main form

Me.Parent.[TextBoxNameInMainForm] = Me.[TextBoxNameInSubForm]

That way this event will be triggered everytime you move a record

--
Good Luck
BS"D


mcgj said:
Thanks for your help. When I use this type of lingo in the code I get the
information for the first record in the datasheet. That is fine when that is
the selected row but when there is more than one record and the user selects
the third row for instance how do I get the data from that row/record?

Thanks!

Ofer Cohen said:
Do you want to refer to that value from the main form?
You can try
Me.[SubFormControlName].Form![TextBoxName]

Or to refer to a text box from a query or out side the form
Forms![MainFormName]![SubFormControlName].Form![TextBoxName]

You can use that also from the main form

--
Good Luck
BS"D


:

I have a form that contains a sub form that is viewed as a datasheet. They
are linked by a single integer field (master/child). I want be able to get
information from the record in the sub form when the user clicks in one of
the text boxes within that record's line in the datasheet. So can I use some
tool or code to find out which record the user has selected?

Thanks for your help!
 

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

Top