Share via

use variable as field name in dlookup function

Anonymous
2018-01-09T08:49:34+00:00

I don’t see explanation by google about using variable as field name in dlookup function, such as 

dlookup (“nz([field1])”,”Table1”,”[field2]”=“ & “‘“ & str1 & “‘“)

how can I use variable strField1, strField2 in place of field1 and field2 above

pls help

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2018-01-09T14:31:19+00:00

It would be (moved your Nz as it didn't make any sense as used):

Nz(DLookup ("[" & strField1 & "]", "Table1", "[" & strField2 & "] = '" & str1 & "'"))

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2018-01-09T09:18:39+00:00

    Hi,

    try with:

    dlookup (nz([strField1]), strField2, ”[field2] ='“ & str1 & “‘“)

    Ciao Mimmo

    Was this answer helpful?

    0 comments No comments