DLookup

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone see what I´m doing wrong here?

I created a textfield in a form.
Then I have tried some different codes for the field.

=DLookup("[A]";"";"[C]=[D]")
This returns the first record in table B.

=DLookup("[A]";"";"[C] = '" & [D] & "'")
This returns the error data type mismatch.

They are all textfields, and I have tried different ways.
Cant get it to work.

I have used DLookup several times before, and it has always worked before.

I´m no expert in any way, so pls be nice to me. :)

/Claes
 
Where are you getting the value for D? Is that the name of a control on
your form?

Is "D" blank (null)?

Are you sure that C and D are both text? What happens if you drop the quote
marks around D?
 
The D is the name of the field in the form.
This has a value.

A and B is text, C and D is a number.
Same fieldsize for C and D.
(I said wrong last time)

I tried dropping the ".
Returns first record in table.



"John Spencer" skrev:
Where are you getting the value for D? Is that the name of a control on
your form?

Is "D" blank (null)?

Are you sure that C and D are both text? What happens if you drop the quote
marks around D?



Claes D said:
Can anyone see what I´m doing wrong here?

I created a textfield in a form.
Then I have tried some different codes for the field.

=DLookup("[A]";"";"[C]=[D]")
This returns the first record in table B.

=DLookup("[A]";"";"[C] = '" & [D] & "'")
This returns the error data type mismatch.

They are all textfields, and I have tried different ways.
Cant get it to work.

I have used DLookup several times before, and it has always worked before.

I´m no expert in any way, so pls be nice to me. :)

/Claes

 
So your DLookup now looks like:
=DLookup("[A]";"";"[C] = " & [D])

And that returns the value of A in first record in Table B? If that is the
case, then I have no idea what is wrong. What do you expect it to return?

Claes D said:
The D is the name of the field in the form.
This has a value.

A and B is text, C and D is a number.
Same fieldsize for C and D.
(I said wrong last time)

I tried dropping the ".
Returns first record in table.



"John Spencer" skrev:
Where are you getting the value for D? Is that the name of a control on
your form?

Is "D" blank (null)?

Are you sure that C and D are both text? What happens if you drop the
quote
marks around D?



Claes D said:
Can anyone see what I´m doing wrong here?

I created a textfield in a form.
Then I have tried some different codes for the field.

=DLookup("[A]";"";"[C]=[D]")
This returns the first record in table B.

=DLookup("[A]";"";"[C] = '" & [D] & "'")
This returns the error data type mismatch.

They are all textfields, and I have tried different ways.
Cant get it to work.

I have used DLookup several times before, and it has always worked
before.

I´m no expert in any way, so pls be nice to me. :)

/Claes

 
I got it to work.

=DLookup("[A]";"";"[C]=Forms![Formname]![D]")

I usually dont have to do like this.
Why does it require that I do this now all of a sudden?

/Claes

"John Spencer" skrev:
Where are you getting the value for D? Is that the name of a control on
your form?

Is "D" blank (null)?

Are you sure that C and D are both text? What happens if you drop the quote
marks around D?



Claes D said:
Can anyone see what I´m doing wrong here?

I created a textfield in a form.
Then I have tried some different codes for the field.

=DLookup("[A]";"";"[C]=[D]")
This returns the first record in table B.

=DLookup("[A]";"";"[C] = '" & [D] & "'")
This returns the error data type mismatch.

They are all textfields, and I have tried different ways.
Cant get it to work.

I have used DLookup several times before, and it has always worked before.

I´m no expert in any way, so pls be nice to me. :)

/Claes

 
I expect it to return a value of A in table B, but the correct record.
Not the first one.

But I´m happy it works in the other way.

It seems like my Access is playing tricks on me.
Another example.
I have a function so I can see who is "logged" on to the database.

When I copied the database, to use for another company, this function no
longer worked.
I have checked it sooo many times, and they are identical.
Still it works in one, but not the other.
Thats funny!!

Thjank you for your help anyway.

BR
Claes

"John Spencer" skrev:
So your DLookup now looks like:
=DLookup("[A]";"";"[C] = " & [D])

And that returns the value of A in first record in Table B? If that is the
case, then I have no idea what is wrong. What do you expect it to return?

Claes D said:
The D is the name of the field in the form.
This has a value.

A and B is text, C and D is a number.
Same fieldsize for C and D.
(I said wrong last time)

I tried dropping the ".
Returns first record in table.



"John Spencer" skrev:
Where are you getting the value for D? Is that the name of a control on
your form?

Is "D" blank (null)?

Are you sure that C and D are both text? What happens if you drop the
quote
marks around D?



Can anyone see what I´m doing wrong here?

I created a textfield in a form.
Then I have tried some different codes for the field.

=DLookup("[A]";"";"[C]=[D]")
This returns the first record in table B.

=DLookup("[A]";"";"[C] = '" & [D] & "'")
This returns the error data type mismatch.

They are all textfields, and I have tried different ways.
Cant get it to work.

I have used DLookup several times before, and it has always worked
before.

I´m no expert in any way, so pls be nice to me. :)

/Claes

 
Back
Top