How can I? (1 Viewer)

littlelis_19

Registered User.
Local time
Today, 10:33
Joined
Oct 12, 2004
Messages
18
How can I get a result from a Query to display in a form?

For example.....I have a database which records staff sickness and I have created a Query which does the following

Days: Sum([Sick Until]-[Sick From])

This calculates the total number of days any one person has taken off due to sickness.

Now I need this figure to display in my form. How can I do this?

PLEASE HELP
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 10:33
Joined
Aug 30, 2003
Messages
36,125
Presuming the control source of the form needs to be some other table or query, a subform or DLookup() would allow you to display the results of that query on your form.
 
K

kingofspoof

Guest
can you explain this further pls?
 

seth_belgium

WoW-Addict
Local time
Today, 19:33
Joined
Oct 4, 2005
Messages
175
A subform can be created by using a wizard, so I don't think we need to elaborate on that.

A DLookup works like this:

Code:
Me.TextBox.Value = DLookup("[FieldnameYouWantToDisplay]", "[NameOfYourQuery]", "[CONDITION]")

The [CONDITION] part is optional. If your query only returns one record, you don't need to use it. If there are more records returned you can build your condition like this:

"[FieldName]=1" or "[FieldName]='String'"

Seth
 

reclusivemonkey

Registered User.
Local time
Today, 18:33
Joined
Oct 5, 2004
Messages
749
kingofspoof, if you want to do something like this and don't understand, you may be better off starting your own thread with more detail of exactly what you want to do and what problems you are having. It is not considered "good form" to "hijack" another user's thread.
 

jrjr

A work in progress
Local time
Today, 13:33
Joined
Jul 23, 2004
Messages
291
Right click your query in the database window and save as a form.
 

Users who are viewing this thread

Top Bottom