Control source

R

Richard

Hi,
I have a text box on my form, I would like to set its control source to a
query. The forms control source is set to a table.

frmEqtag
qryEquipTag
txtBarcode

I tried this
=[qryEquipTag]![Asset Tag]

Thank you
 
J

John Spencer

You cannot set a text box control source to a query. Perhaps you can use
=DLookup("[Asset Tag]","QryEquipTag")

That will grab the first value it finds for Asset Tag in a query named
qryEquipTag.

If you want a more detailed answer, you are going to need to post a lot
more information on what you are trying to acccomplish.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
R

Richard

Hi John,

The text box has its font set to BCW_Code128B_2 barcode. I was hoping to
reference asset tag within qryEpuipTag so the user could see the barcode they
were creating. The report works but id like to have the visual on the form if
possible. I tried your suggestion and so far its just grabbing the first
instance it comes to.

John Spencer said:
You cannot set a text box control source to a query. Perhaps you can use
=DLookup("[Asset Tag]","QryEquipTag")

That will grab the first value it finds for Asset Tag in a query named
qryEquipTag.

If you want a more detailed answer, you are going to need to post a lot
more information on what you are trying to acccomplish.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Hi,
I have a text box on my form, I would like to set its control source to a
query. The forms control source is set to a table.

frmEqtag
qryEquipTag
txtBarcode

I tried this
=[qryEquipTag]![Asset Tag]

Thank you
 
F

fredg

Hi John,

The text box has its font set to BCW_Code128B_2 barcode. I was hoping to
reference asset tag within qryEpuipTag so the user could see the barcode they
were creating. The report works but id like to have the visual on the form if
possible. I tried your suggestion and so far its just grabbing the first
instance it comes to.

John Spencer said:
You cannot set a text box control source to a query. Perhaps you can use
=DLookup("[Asset Tag]","QryEquipTag")

That will grab the first value it finds for Asset Tag in a query named
qryEquipTag.

If you want a more detailed answer, you are going to need to post a lot
more information on what you are trying to acccomplish.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
Hi,
I have a text box on my form, I would like to set its control source to a
query. The forms control source is set to a table.

frmEqtag
qryEquipTag
txtBarcode

I tried this
=[qryEquipTag]![Asset Tag]

Thank you

If you wish the value of a particular record, then you must add a
Where clause to the DLookUp so Access knows which record value to
return.
Look up, in VBA help, DLookUp, Where clause, and Restrict data to a
subset of records.
 
R

Richard

Hi,

I checked the help file on Dlookup and tried out a few things but I can only
get one record to display.

=DLookUp("[asset tag]","qryEquipTag","[assetid]"

It seems that I am close but still can't make this work.


fredg said:
Hi John,

The text box has its font set to BCW_Code128B_2 barcode. I was hoping to
reference asset tag within qryEpuipTag so the user could see the barcode they
were creating. The report works but id like to have the visual on the form if
possible. I tried your suggestion and so far its just grabbing the first
instance it comes to.

John Spencer said:
You cannot set a text box control source to a query. Perhaps you can use
=DLookup("[Asset Tag]","QryEquipTag")

That will grab the first value it finds for Asset Tag in a query named
qryEquipTag.

If you want a more detailed answer, you are going to need to post a lot
more information on what you are trying to acccomplish.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Richard wrote:
Hi,
I have a text box on my form, I would like to set its control source to a
query. The forms control source is set to a table.

frmEqtag
qryEquipTag
txtBarcode

I tried this
=[qryEquipTag]![Asset Tag]

Thank you

If you wish the value of a particular record, then you must add a
Where clause to the DLookUp so Access knows which record value to
return.
Look up, in VBA help, DLookUp, Where clause, and Restrict data to a
subset of records.
 
F

fredg

Hi,

I checked the help file on Dlookup and tried out a few things but I can only
get one record to display.

=DLookUp("[asset tag]","qryEquipTag","[assetid]"

It seems that I am close but still can't make this work.

fredg said:
Hi John,

The text box has its font set to BCW_Code128B_2 barcode. I was hoping to
reference asset tag within qryEpuipTag so the user could see the barcode they
were creating. The report works but id like to have the visual on the form if
possible. I tried your suggestion and so far its just grabbing the first
instance it comes to.

:

You cannot set a text box control source to a query. Perhaps you can use
=DLookup("[Asset Tag]","QryEquipTag")

That will grab the first value it finds for Asset Tag in a query named
qryEquipTag.

If you want a more detailed answer, you are going to need to post a lot
more information on what you are trying to acccomplish.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Richard wrote:
Hi,
I have a text box on my form, I would like to set its control source to a
query. The forms control source is set to a table.

frmEqtag
qryEquipTag
txtBarcode

I tried this
=[qryEquipTag]![Asset Tag]

Thank you

If you wish the value of a particular record, then you must add a
Where clause to the DLookUp so Access knows which record value to
return.
Look up, in VBA help, DLookUp, Where clause, and Restrict data to a
subset of records.

How is Access going to know which [Asset tag] record to return?
That's what the Where clause (without the word Where) tells it.
So, let's assume that [asserid] is the name of the record's prime key
field.
Let's also assume that the [assetid] field is a Number datatype.
The where clause must be a string.
So, "[assetid] = SomeNumberValue" will return the correct [asset tag]
value.
I'll assume that the form is displaying the [assetid] prime key value
that you wish to get the [asset tag] value on. We'll also, just for
this example, say that the record being displayed on the form is
[assetid] = 123. That 123 prime key value must be concatenated into
the where clause argument, so that it will look like:
"[assetid] = 123"

Here is the syntax for DLookUp, using a where clause in which the
criteria value is a Number datatype, and is currently the record that
has the focus on the form:

=DLookUp("[asset tag]","qryEquipTag","[assetid] = " & Me.[assetid])

If [assetid] is a text datatype, then the syntax would be:
"[assetid] = '" & Me.[assetid] & "'")

The correct syntax for the different datatypes is found in VBA help,
if you read the topics I gave you in my previous reply.
 
R

Richard

Takes a while to wrap your mind around it ...but ty for all your help works
and looks great!

fredg said:
Hi,

I checked the help file on Dlookup and tried out a few things but I can only
get one record to display.

=DLookUp("[asset tag]","qryEquipTag","[assetid]"

It seems that I am close but still can't make this work.

fredg said:
On Wed, 9 Jul 2008 16:01:09 -0700, Richard wrote:

Hi John,

The text box has its font set to BCW_Code128B_2 barcode. I was hoping to
reference asset tag within qryEpuipTag so the user could see the barcode they
were creating. The report works but id like to have the visual on the form if
possible. I tried your suggestion and so far its just grabbing the first
instance it comes to.

:

You cannot set a text box control source to a query. Perhaps you can use
=DLookup("[Asset Tag]","QryEquipTag")

That will grab the first value it finds for Asset Tag in a query named
qryEquipTag.

If you want a more detailed answer, you are going to need to post a lot
more information on what you are trying to acccomplish.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Richard wrote:
Hi,
I have a text box on my form, I would like to set its control source to a
query. The forms control source is set to a table.

frmEqtag
qryEquipTag
txtBarcode

I tried this
=[qryEquipTag]![Asset Tag]

Thank you


If you wish the value of a particular record, then you must add a
Where clause to the DLookUp so Access knows which record value to
return.
Look up, in VBA help, DLookUp, Where clause, and Restrict data to a
subset of records.

How is Access going to know which [Asset tag] record to return?
That's what the Where clause (without the word Where) tells it.
So, let's assume that [asserid] is the name of the record's prime key
field.
Let's also assume that the [assetid] field is a Number datatype.
The where clause must be a string.
So, "[assetid] = SomeNumberValue" will return the correct [asset tag]
value.
I'll assume that the form is displaying the [assetid] prime key value
that you wish to get the [asset tag] value on. We'll also, just for
this example, say that the record being displayed on the form is
[assetid] = 123. That 123 prime key value must be concatenated into
the where clause argument, so that it will look like:
"[assetid] = 123"

Here is the syntax for DLookUp, using a where clause in which the
criteria value is a Number datatype, and is currently the record that
has the focus on the form:

=DLookUp("[asset tag]","qryEquipTag","[assetid] = " & Me.[assetid])

If [assetid] is a text datatype, then the syntax would be:
"[assetid] = '" & Me.[assetid] & "'")

The correct syntax for the different datatypes is found in VBA help,
if you read the topics I gave you in my previous reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top