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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting data from a subform 1

Status
Not open for further replies.

docliv

Technical User
Nov 11, 2002
21
US
Hi all,
I'm fairly new at access, but I'm jumping in deep and designing an application right now. Despite the hair pulling and gnashing of teeth..it is an interesting undertaking. My problem..or should I say what I would like to do is get data from a subform on to the main form.
What I have is a main form and a subform that lists a 5 x 5 grid of data (i.e. 25 pieces of information) based on a link on the main form, so this information changes depending on the linked item on the main form. This all works great with the subform only display the data that relates to the main form. What I would like to do is have the ablility to take one of the 25 pieces of information that is supplied on the subform and make an entry on the main form so the underlying table is undated with this info. Does this make any sense? and does anyone have an idea how to do this? Thanks in advance for any response.

Terry
 
Not sure what you're trying to do. But, to access a control on a subform, the syntax is this:

Forms!subFormControlName.form!ControlName

Where "subFormControlName" is the name of the control that contains the subform (generally the same name as the subform).
 
oops! Hit the submit button too soon. The syntax should be:

Forms!MainFormName!subFormControlName.form!ControlName

or

Me!subFormControlName.form!ControlName
 
Thanks for the info, I'm sure I wasn't too clear on what I was trying to do. Basically, my subform will have a grid containing 25 different codes. Right now i just pick the code that is in the correct grid position and enter it in the field that needs this data on the main form. It would be nice if I could just click the code in one the the 25 "cells" on my grid and get it to go into the field on the main form. Will what you were describing do this? Is it possible to put a transparent control over the code area to do this? Any ideas? Again thanks a bunch for your help. I've learned more about access from going thru these forums than any help index.

Terry
 
If I understand you correctly, when the user clicks on a cell, you want to take the value in the cell and place it on a field in the main form. If this is true, you will need to call a function via the OnClick event of each of the cells. The code should look something like this:

Function UpdateMainTextField()

Dim ctrl as Control

Set ctrl = Screen.ActiveControl

Forms!MainForm!txtField = ctrl.Value

End Function
 
FancyPrairie, thanks a bunch...you hit the nail right on the head...your code example was exactly what I needed..Thanks ever so much..I just made a vote for you for tipmaster of the week. I am amazed at the body of knowledge out there and the expertise of people like you.
I hope you all are making the big bucks somewhere.
Again thanks ever so much.

Terry Livingston (still learning access..and to hard headed to give up ;>)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top