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

Copy results from Search form to a subform

Status
Not open for further replies.

dbar10

Programmer
Dec 5, 2008
196
US
I have a main form that has the medical record of a client. There is a subform that holds multiple medications the client is taking in datasheet view. I have a search form that is called up from a command button on the main form. I need to take the results from the Search Form, field name([Brand Name])and assign that result to a new record in the subform, field name [Meds].

Main form is [POC Form]
Subform is [POCMed Subform]
Search form is [Med Search Form]

I hope you can understand what I've written.

I have been hammering on this a long time and just can't get it. If you can help it would be very appreciated.
 
You probably need to provide a little information of what you have and where you are having problem. Here are some general ideas. If you open a form from the Docmd.openform and choose "acdialog" then code execution stops until the form is closed.
ex:
Public Sub openform()
DoCmd.openform "Categories", , , , , acDialog
'code does not start again until form Categories is closed or hidden

End Sub

So this is how I make a form return a value/s.
1)open the form in dialog in your code stops
2)Put an ok , cancel button on the search form
Ok sets the form to visible = false. This hides it but does not close it.
Cancel closes the form
3)Once hidden or closed code execution continues from where you called the form.
4)Check if the form is loaded. If not the user canceled the form so do nothing
5)If it is loaded but hidden grab the values you need from the form
6)put the values in the calling form
7)close the hidden form
 
Thank you, I'll give that a shot and let you know what happens.
 
I have been working on this all night and all day. I am worn out. I am writing a macro to accomplish the above task. here's the breakdown in Access.

Echo
Off
OpenForm
POCMedSubform
Add
Hidden
GotoRecord
POCMedSubform
New
SetValue
Item=[Forms]![POC Form]![POCMed Subform].Form]![Meds]

Expression=Forms]![Medications Search Results]![Brand Name]

Close
POCMedSubform
Close
Medication Search Results
Close
MedSearchForm
Echo
True


This work real good but I will need to make multiple entries in one session and I can't get the focus on a new record in my subform after running this so that the next entry will go as a new record and not just write over the last record. Does that make sense?
 
How are ya dbar10 . . .

Whats the name of the table [blue][POCMed Subform][/blue] is based on? ... I have code but need this name ...

Also, is it possibe for the search form to return more than ove value?

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
It's based on the POCMed Table Query. The table for the query is POCMed Table.
The search form does return multiple choices but they are displayed in form view one at a time. Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top