dlookup

  • Thread starter Thread starter nevinx
  • Start date Start date
N

nevinx

Is it possible to use Dlookup to look up a record based on two different
parameters to fill in a text box?
 
Yes: you can use an AND in the criteria, e.g.:

=DLookup("CompanyName", "tblCompany", "(City = """ & [txtWotCity] & """) AND
(State = """ & [txtWotState] & """)")
 
Is it possible to use Dlookup to look up a record based on two different
parameters to fill in a text box?

Yes, but without knowing more details it's hard to know how to write
it.
Here is the basic syntax.

=DLookUp("[FieldName]","TableName","[SomeField] = SomeCriteria And
[SomeOtherField] = SomeOtherCriteria")
 
I'm still having troubles. Here are a few more details. The form is called
"Process change form". I want the text box labeled "setting" to fill in with
a value stored in the table "set-up sheets". In order to do that it has to
lookup the value based on what is in the combo box labeled "line" and the
combo box labeled "parameter."

fredg said:
Is it possible to use Dlookup to look up a record based on two different
parameters to fill in a text box?

Yes, but without knowing more details it's hard to know how to write
it.
Here is the basic syntax.

=DLookUp("[FieldName]","TableName","[SomeField] = SomeCriteria And
[SomeOtherField] = SomeOtherCriteria")
 
I'm still having troubles. Here are a few more details. The form is called
"Process change form". I want the text box labeled "setting" to fill in with
a value stored in the table "set-up sheets". In order to do that it has to
lookup the value based on what is in the combo box labeled "line" and the
combo box labeled "parameter."

fredg said:
Is it possible to use Dlookup to look up a record based on two different
parameters to fill in a text box?

Yes, but without knowing more details it's hard to know how to write
it.
Here is the basic syntax.

=DLookUp("[FieldName]","TableName","[SomeField] = SomeCriteria And
[SomeOtherField] = SomeOtherCriteria")

Still not enough information.

In order to properly use a DLookUp you must know the datatypes of the
criteria fields.

1) What is the datatype of the *bound* column of the combo box named
"Line"? Number or Text or Date?
2) What is the actual name of the field in the table that contains the
'line' criteria? Does it's datatype match the datatype of the combo's
bound column?
3) What is the actual name of the other field in the table that
contains the 'parameter' criteria? Does it's datatype match the
datatype of the combo's bound column?
4) What is the datatype of the *bound* column of the combo box named
"parameter"? Number or Text or Date?
5) What is the name of the field in the table "set-up sheets" that
contains the value you wish to look up?
 
fredg said:
I'm still having troubles. Here are a few more details. The form is called
"Process change form". I want the text box labeled "setting" to fill in with
a value stored in the table "set-up sheets". In order to do that it has to
lookup the value based on what is in the combo box labeled "line" and the
combo box labeled "parameter."

fredg said:
On Tue, 24 Jun 2008 19:15:00 -0700, nevinx wrote:

Is it possible to use Dlookup to look up a record based on two different
parameters to fill in a text box?

Yes, but without knowing more details it's hard to know how to write
it.
Here is the basic syntax.

=DLookUp("[FieldName]","TableName","[SomeField] = SomeCriteria And
[SomeOtherField] = SomeOtherCriteria")

Still not enough information.

In order to properly use a DLookUp you must know the datatypes of the
criteria fields.

1) What is the datatype of the *bound* column of the combo box named
"Line"? Number or Text or Date? Text
2) What is the actual name of the field in the table that contains the
'line' criteria? Does it's datatype match the datatype of the combo's
bound column? Line and yes it does
3) What is the actual name of the other field in the table that
contains the 'parameter' criteria? Does it's datatype match the
datatype of the combo's bound column? Parameter and yes it does
4) What is the datatype of the *bound* column of the combo box named
"parameter"? Number or Text or Date? text
5) What is the name of the field in the table "set-up sheets" that
contains the value you wish to look up? setting
 
fredg said:
I'm still having troubles. Here are a few more details. The form is called
"Process change form". I want the text box labeled "setting" to fill in with
a value stored in the table "set-up sheets". In order to do that it has to
lookup the value based on what is in the combo box labeled "line" and the
combo box labeled "parameter."

:

On Tue, 24 Jun 2008 19:15:00 -0700, nevinx wrote:

Is it possible to use Dlookup to look up a record based on two different
parameters to fill in a text box?

Yes, but without knowing more details it's hard to know how to write
it.
Here is the basic syntax.

=DLookUp("[FieldName]","TableName","[SomeField] = SomeCriteria And
[SomeOtherField] = SomeOtherCriteria")

Still not enough information.

In order to properly use a DLookUp you must know the datatypes of the
criteria fields.

1) What is the datatype of the *bound* column of the combo box named
"Line"? Number or Text or Date? Text
2) What is the actual name of the field in the table that contains the
'line' criteria? Does it's datatype match the datatype of the combo's
bound column? Line and yes it does
3) What is the actual name of the other field in the table that
contains the 'parameter' criteria? Does it's datatype match the
datatype of the combo's bound column? Parameter and yes it does
4) What is the datatype of the *bound* column of the combo box named
"parameter"? Number or Text or Date? text
5) What is the name of the field in the table "set-up sheets" that
contains the value you wish to look up? setting

A text datatype must be surrounded with "quotes" (double quotes,
unless double quotes are already used in the syntax, then single
'quotes' are used).

=DLookUp("[Setting]","set-up sheets","[Line] = '" & [Line] & "' AND
[Parameter] = '" & [Parameter] & "'")

Just for clarity here is the above where clause with spaces between
the quotes:
"[Line] = ' " & [Line] & " ' AND [Parameter] = ' " & [Parameter] & " '
")

You really should use a naming convention for your controls, i.e.
instead of Line use cboLine or cmbLine to differentiate the control
name on the form from the Line field in your table. It makes for less
errors in coding and is more easily read and understood, months in the
future, when you have forgotten what is happening here in your code.
 
Thanks for the help and the advice.

fredg said:
fredg said:
On Wed, 25 Jun 2008 14:48:01 -0700, nevinx wrote:

I'm still having troubles. Here are a few more details. The form is called
"Process change form". I want the text box labeled "setting" to fill in with
a value stored in the table "set-up sheets". In order to do that it has to
lookup the value based on what is in the combo box labeled "line" and the
combo box labeled "parameter."

:

On Tue, 24 Jun 2008 19:15:00 -0700, nevinx wrote:

Is it possible to use Dlookup to look up a record based on two different
parameters to fill in a text box?

Yes, but without knowing more details it's hard to know how to write
it.
Here is the basic syntax.

=DLookUp("[FieldName]","TableName","[SomeField] = SomeCriteria And
[SomeOtherField] = SomeOtherCriteria")
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail


Still not enough information.

In order to properly use a DLookUp you must know the datatypes of the
criteria fields.

1) What is the datatype of the *bound* column of the combo box named
"Line"? Number or Text or Date? Text
2) What is the actual name of the field in the table that contains the
'line' criteria? Does it's datatype match the datatype of the combo's
bound column? Line and yes it does
3) What is the actual name of the other field in the table that
contains the 'parameter' criteria? Does it's datatype match the
datatype of the combo's bound column? Parameter and yes it does
4) What is the datatype of the *bound* column of the combo box named
"parameter"? Number or Text or Date? text
5) What is the name of the field in the table "set-up sheets" that
contains the value you wish to look up? setting

A text datatype must be surrounded with "quotes" (double quotes,
unless double quotes are already used in the syntax, then single
'quotes' are used).

=DLookUp("[Setting]","set-up sheets","[Line] = '" & [Line] & "' AND
[Parameter] = '" & [Parameter] & "'")

Just for clarity here is the above where clause with spaces between
the quotes:
"[Line] = ' " & [Line] & " ' AND [Parameter] = ' " & [Parameter] & " '
")

You really should use a naming convention for your controls, i.e.
instead of Line use cboLine or cmbLine to differentiate the control
name on the form from the Line field in your table. It makes for less
errors in coding and is more easily read and understood, months in the
future, when you have forgotten what is happening here in your code.
 
Back
Top