Full Version: Field Parameter that runs a Query
UtterAccess Forums > Microsoft® Access > Access Forms
I was hoping for some insight into how to correct the following issue. I have an unbound text field on a form that exectutes a query and that part works fine. What I would like to do is have the three other fields in the query populate the fields in my form. I am not sure why it isn't working. The query shows for example One, Two, Three, Four. The unbound field that exectutes the query is One and I would like the fields for Two, Three, and Four be shown in the form.
Thank you,
It might help to see the code used to populate the first one.
On the form field [UnitID] is used on the qryUnitID to run the query as the parameter. On the query in the criteria field I have [forms]![fmrmainpageproject].[unitid]. Once the query is executed there are four fields for the record. On the form the only field that as anything in it is the unitID field. I am trying to have the three other fields for the record show on the form. The forms control source is qryUnitID. I don't realy have any other code to show.
I'm not really picturing what you have then. If the form is bound to the query, then you should be able to add 3 more textboxes and bind them to the other 3 fields. Or can you post a sample?
Sorry for not making this clear, but I will try again. I have a form [fmrmainpageproject] whose control source is query qryFireUnitID. On the for I have these fields:
The UnitID field is unbound. The other three are bound to the qryfireunitID with their field names.
On the qry I have in the FireUnitID field the following in the criteria section [forms]![fmrmainpageproject].[fireunitid]. When I enter a value in the field FireunitID on the form it does bring the query up with the records four fields. The FireUnitID field has the correct value but the other three a blank. I hope this is a better explanation.
Pardon me for jumping in here...
eo, if you just want a look up...
=DLookUp("[FieldNameToDisplay]","[TblOfDataYouWantDisplayed]","[FireUnitID] = " & Forms("FrmMainPageProject")("[FireUnitID]"))
... where [FireUnitID] is your unique ID#... to help identify what value to show between your table and form. This value would go inside of an unbound text box.
However, if you would like to edit this information, Here's what I would do...
1) Turn off your "Use Control Wizard" (Looks like a little magic wand)
2) Click on the button in your toolbox that says: "Subform/Subreport" and place it somewhere on your form.
3) Open it's properties and change the following:
A) Source Object (The query you are basing it off of)
B) Link Master Fields (Probably your FireUnitID)
C) Link Child Fields (Same as your Master Fields)
4) On your main form, where you type in your [FireUnitID], select it's properties.
5) Select one of the "Events", such as Lost Focus or After Update... and select in there [Event Procedure]. We are now going to add a small snipit of code.
6) In between your Private Sub and End Sub, insert this line of code:
Your "NameOfFireUnitIDField" might be something like "Text4" or something of the like. This is just the name of the text box that houses your value.
This bit of code should (In theory), save your selection and update the query you have displayed on your form. This information, can be edited. . . Most of the time. Just as long as it is just pulling data from your table and not doing anything fancy with it, you should be able to view & edit your data inside of the Query box you just setup on your main form.
Hope this helps.
Hi Josh,
Thanks for your thoughts. It worked just the way it should have. As soon as I started to look over what you had written it all seemed to fall into place. Again Thank You and Take care,
Yea! sad.gif
He love it when things fall in place!
May all of your future designs come easily!
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.