DLookup referencing a subform

  • Thread starter Stella Pieters via AccessMonster.com
  • Start date
S

Stella Pieters via AccessMonster.com

L.S.

The intention of the following code is to lookup the artDescrip in the
contraceptive table, using the description (which is a combobox) from the
subform visits1. The main form is called "registration form".

I coded it as follows:


Dim varX As Variant

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Transaction Table", dbOpenTable)

varX = DLookup("[ArtDescrip]", "Contraceptives", "[Contraceptives] = '" _
& Forms![REGISTRATION FORM]![visits1]!Contraceptives)

rst("ArtDescrip") = varX

Could you please give me a hint on how to do this, as I'm getting the run
error 438, saying that "object does not support this object or method".

Thanks in advance

Stella Pieters
 
M

Marshall Barton

Stella said:
The intention of the following code is to lookup the artDescrip in the
contraceptive table, using the description (which is a combobox) from the
subform visits1. The main form is called "registration form".

I coded it as follows:

Dim varX As Variant

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Transaction Table", dbOpenTable)

varX = DLookup("[ArtDescrip]", "Contraceptives", "[Contraceptives] = '" _
& Forms![REGISTRATION FORM]![visits1]!Contraceptives)

rst("ArtDescrip") = varX

Could you please give me a hint on how to do this, as I'm getting the run
error 438, saying that "object does not support this object or method".


The DLookup needs the closing quotes on the condition:

varX = DLookup("[ArtDescrip]", "Contraceptives", _
"[Contraceptives] = '" & _
Forms![REGISTRATION FORM]![visits1]!Contraceptives & "'")

But it seems like the rules of normalization preclude doing
this. As long as the transaction table has the
Contraceptives field, there is no need to copy the
ArtDescrip from the Contraceptives table.
 

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