Lookup query results field on form?

bluke

Registered User.
Local time
Today, 17:50
Joined
Apr 12, 2006
Messages
33
I'd like to create a form that looks up info in a query that has three fields (date, department, sales volume) The form would have a combo box to select department, text field to enter the date and the third box would automatically populate the volume based on the criteria in the other 2? Anyone have suggestions on how to do this?

Thanks.

bluke
 
Handle the after update events of the combo and the textbox, and from each one run a routine that calculates your result, which you can assign to the final textbox. Code would look something like...

Code:
private sub combo_click()
  calcresult
end sub

private sub text_afterupdate()
  calcresult
end usub

private sub calcresult()
[COLOR="Green"]  'establish that there is usable data in both source controls
  'you can write cooler validation code here[/COLOR]
  if nz(combo, "") <> "" and nz(text, "") <> "" then
[COLOR="green"]    'do calculation or lookup here and assign to result text box[/COLOR]
    txtResult = DLookup( _
      "field", "query", "department = " & combo & " [date] = #" & text & "#")
  end if
end sub
 

Users who are viewing this thread

Back
Top Bottom