I am trying to do a dlookup to fill in a description field on a form based on a number that might be stored in either of two other tables. I have CP numbers and A numbers. If the user types a CP number in I want the Dlookup to go to the CP Numbers table. If the user types in an A number I want the Dlookup to go to the AO Numbers table. Here is the code I am using
If Forms![Proposals]![CP_AO_Number] Like "[CP]*" Then
Forms![Proposals]![Description] = DLookup("[CP_Description]", "[CP_Numbers]", "[Forms]![proposals]![cp_ao_number]")
ElseIf Forms![Proposals]![CP_AO_Number] Like "[A]*" Then
Forms![Proposals]![Description] = DLookup("[AO_Description]", "AO_Numbers", "[Forms]![proposals]![cp_ao_number]")
When the user types in a CP number this code returns a description, but not the one that applies to the particular number the user typed in. When the user types in an A number, no description is returned at all.
Can someone please show me the error of my ways?
Thanks!
Erika
If Forms![Proposals]![CP_AO_Number] Like "[CP]*" Then
Forms![Proposals]![Description] = DLookup("[CP_Description]", "[CP_Numbers]", "[Forms]![proposals]![cp_ao_number]")
ElseIf Forms![Proposals]![CP_AO_Number] Like "[A]*" Then
Forms![Proposals]![Description] = DLookup("[AO_Description]", "AO_Numbers", "[Forms]![proposals]![cp_ao_number]")
When the user types in a CP number this code returns a description, but not the one that applies to the particular number the user typed in. When the user types in an A number, no description is returned at all.
Can someone please show me the error of my ways?
Thanks!
Erika