question

SaraCastro-1613 avatar image
0 Votes"
SaraCastro-1613 asked SaraCastro-1613 commented

dpesquisar _ ACESS

=DPesquisar("[CodigoSistemaPainel]";"Correspondencia";"[Modelo]='" & [Modelo] & "' and [Vidro]='" & [Vidro] & "' and [Espacador] ='" & [Espacador] & "' and [Triplo] ='" & [Triplo] & "' and [Espessura]=" & [Espessura])

Don't working :/
What's the problem?

office-access-dev
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

What are the data types of each field you are using I'm your expression?

Only text field need to be surrounded by quotes, otherwise if they are numeric you should use any quotes.

One trick that can need useful sometimes it's to debug the criteria expression and plug it into a query and adjust it there. Once you get the basic syntax working you can then comes back and adjust your expression to match.

1 Vote 1 ·

1 Answer

KarlDonaubauer avatar image
0 Votes"
KarlDonaubauer answered SaraCastro-1613 commented

Hi,

The syntax looks ok. Test the expression step by step. Start with

=DPesquisar("[CodigoSistemaPainel]";"Correspondencia")

If that works, the next test should be

=DPesquisar("[CodigoSistemaPainel]";"Correspondencia";"[Modelo]='" & [Modelo] & "'")

then

=DPesquisar("[CodigoSistemaPainel]";"Correspondencia";"[Modelo]='" & [Modelo] & "' and [Vidro]='" & [Vidro] & "'")

etc.

Until you find the part that doesn't work. Usually it is a naming or data type problem or a missing field.

If you don't succeed then tell what exactly happens and what error you get.

Servus
Karl


http://AccessDevCon.com
https://www.donkarl.com

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Thank you for your help!
I've tried it, but it just fails in the "Glass" field.
I think it's because this field is not always filled. How to get around this?

0 Votes 0 ·

Hi,

You still didn't explain what "fails" means.
If you just don't get a result because of an empty field then try to use nz():

=DPesquisar("[CodigoSistemaPainel]";"Correspondencia";"[Modelo]='" & [Modelo] & "' and nz([Vidro])='" & nz([Vidro]) & ...

Servus
Karl
http://AccessDevCon.com
https://www.donkarl.com

1 Vote 1 ·

The fail is "#ERRO".

Nz effectively solved my problem.
Thank you very much for your help! I wasted a lot of time trying to find the error!
had just used the [Vidro]'" & nz ([Vidro]) & " and not nz ([Vidro]) = '" & nz ([Vidro]) & ....
It already works!! :)

0 Votes 0 ·