How do you display results of query in textbox

K

krharrison

How do you display the results in a textbox from a query in an exit event of
a previous textbox?
 
F

fredg

How do you display the results in a textbox from a query in an exit event of
a previous textbox?

Use a DLookUp.

If the query returns just one record:
[ControlName]=DLookUp("[FieldName]","QueryName")

If the query returns more than one record....
If [Somefield] is a Number datatype, use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] = " &
SomeNumberCriteria)

If [SomeField] is Text datatype use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] ='" &
SomeTextCriteria & "'")

In VBA help, look up DLookUp
as well as
Where clause + Restrict data to a subset of records.
 
K

krharrison

This worked beautifully ! ! ! Many thanks ! !



fredg said:
How do you display the results in a textbox from a query in an exit event of
a previous textbox?

Use a DLookUp.

If the query returns just one record:
[ControlName]=DLookUp("[FieldName]","QueryName")

If the query returns more than one record....
If [Somefield] is a Number datatype, use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] = " &
SomeNumberCriteria)

If [SomeField] is Text datatype use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] ='" &
SomeTextCriteria & "'")

In VBA help, look up DLookUp
as well as
Where clause + Restrict data to a subset of records.
 
A

adsl

fredg said:
How do you display the results in a textbox from a query in an exit event
of
a previous textbox?

Use a DLookUp.

If the query returns just one record:
[ControlName]=DLookUp("[FieldName]","QueryName")

If the query returns more than one record....
If [Somefield] is a Number datatype, use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] = " &
SomeNumberCriteria)

If [SomeField] is Text datatype use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] ='" &
SomeTextCriteria & "'")

In VBA help, look up DLookUp
as well as
Where clause + Restrict data to a subset of records.
 
A

adsl

krharrison said:
This worked beautifully ! ! ! Many thanks ! !



fredg said:
How do you display the results in a textbox from a query in an exit
event of
a previous textbox?

Use a DLookUp.

If the query returns just one record:
[ControlName]=DLookUp("[FieldName]","QueryName")

If the query returns more than one record....
If [Somefield] is a Number datatype, use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] = " &
SomeNumberCriteria)

If [SomeField] is Text datatype use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] ='" &
SomeTextCriteria & "'")

In VBA help, look up DLookUp
as well as
Where clause + Restrict data to a subset of records.
 
A

adsl

krharrison said:
This worked beautifully ! ! ! Many thanks ! !



fredg said:
How do you display the results in a textbox from a query in an exit
event of
a previous textbox?

Use a DLookUp.

If the query returns just one record:
[ControlName]=DLookUp("[FieldName]","QueryName")

If the query returns more than one record....
If [Somefield] is a Number datatype, use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] = " &
SomeNumberCriteria)

If [SomeField] is Text datatype use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] ='" &
SomeTextCriteria & "'")

In VBA help, look up DLookUp
as well as
Where clause + Restrict data to a subset of records.
 
A

adsl

fredg said:
How do you display the results in a textbox from a query in an exit event
of
a previous textbox?

Use a DLookUp.

If the query returns just one record:
[ControlName]=DLookUp("[FieldName]","QueryName")

If the query returns more than one record....
If [Somefield] is a Number datatype, use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] = " &
SomeNumberCriteria)

If [SomeField] is Text datatype use:
[ControlName]=DLookUp("[FieldName]","QueryName","[SomeField] ='" &
SomeTextCriteria & "'")

In VBA help, look up DLookUp
as well as
Where clause + Restrict data to a subset of records.
 
Top