Put data from Query in Unbound control

michaeljryan78

Registered User.
Local time
Today, 13:58
Joined
Feb 2, 2011
Messages
165
I am going to try and explian this the best way I know how:

I have a form based on a table [counseldetails] and I would like to place the results of a matematical query ((budget + budget adjustments) = currnetbudget) only when the requestID of the counseldetals table matches the requestID of the query, so for the request ID I will have a current budget displayed.

Budget adjustments lie withing their own table
counseldetails has the budget and the quesry is adding the budget plus any adjustments based on the requestID.

Any help would be great....
 
A form raises a Current event whenever a new record is loaded. Handle this event to perform calculations specific to individual records. To get data out of a query use the query to open a recordset and get data out of the recordset.
It is common that you would open a recordset in the Current event of a form to display complex data relating to the current record.
Cheers,
Mark
 
You can't assign the results of a query directly into a Control on a Form, you have to use the DLookup() function.

Replacing example names with your actual names:

'If requestID is Numeric
Code:
Me.UnboundControl= DLookup("CurrentBudget", "QueryName", "requestID = " & Me.requestID)
'If requestID is Text
Code:
Me.UnboundControl= DLookup("CurrentBudget", "QueryName", "[requestID] = '" & Me.requestID & "'")
Linq ;0)>
 
I am sorry, I may be a bit more noob than I thought. I didn't quite uderstand what you are saying above.

I would really rather not redesign my form to pull from a query rather than the table (counseldetails). If you can please guide me to figure this one out, I would really appreciate it. Here is the background info:

Table Counseldetails
requestID
Budget
Table budgetadjDetails
requestID(counseldetails)
budgetadjust

Here, for every request there is a budget and there may be several adjustments per request, and I would like to display the CurentBudget using results that I have queried together on the form derived from the counseldetails recorset where the query currentbudget.requestID = Forms!counseldetails!requestID.
 
thanks linq!

Where do I put the code? (the ID is numeric) and is the code changed if I want the requestID from the form instead of the table? (I think forms!counseldetails.requestID or something like that).

It almost makes sense to put the code in the OnCurrnet Event so I can cycle through records and see the updated budgets....
 
thanks for the guidance!!

here is the code that worked in the forms OnCurrnet event:

Me.Text108 = DLookup("CurrentBudget", "currentbudgetforform", "ID =" & Me.ID)
 

Users who are viewing this thread

Back
Top Bottom