IF Statement not working?

  • Thread starter gchichester via AccessMonster.com
  • Start date
G

gchichester via AccessMonster.com

Can anyone find a reason why this IF Statement only returns a "N/A".
To the best of my ability I have confirmed that all the data in the
referenced field is correct and
should populate the [AsiaNoticeContractNumber] with the correct number.

Thanks for any and all responses.
Gilc


Private Sub cboAsiaNoticeServiceContractCustomer_LostFocus()

If [cboAsiaNoticeShipLine] = "FE Evergreen" And
[cboAsiaNoticeServiceContractCustomer] = "CELSUS EXPORT LLC." Then
'Celsus/FE-Evergreen '
[AsiaNoticeContractNumber] = "35378"

ElseIf [cboAsiaNoticeShipLine] = "FE OOCL" And
[cboAsiaNoticeServiceContractCustomer] = "CELSUS EXPORT LLC." Then
'Celsus/FE-OOCL'
[AsiaNoticeContractNumber] = "PW082185"

ElseIf [cboAsiaNoticeShipLine] = "FE Mitsui" And
[cboAsiaNoticeServiceContractCustomer] = "CELSUS EXPORT LLC." Then
'Celsus/MITSUI'
[AsiaNoticeContractNumber] = "5110125A08"

ElseIf [cboAsiaNoticeShipLine] = "FE Maersk" And
[cboAsiaNoticeServiceContractCustomer] = "CELSUS EXPORT LLC." Then
'Celsus/Mearsk - 01/09
[AsiaNoticeContractNumber] = "271912"

Else: [AsiaNoticeContractNumber] = "N/A"

End If
End Sub
 
J

Jeff Boyce

I'll take a wild stab and ask if the data field (in the table) underlying
[cboAsiaNoticeShipLine] is set up as a "Lookup" data type? That data type
displays one thing (e.g., "FE Evergreen"), but is actually storing something
else (the primary key of the record containing that looked up value).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

gchichester via AccessMonster.com

Jeff,
I checked the AsiaNoticeShipLine in table design and Lookup tab is set to
textbox.
But I did find this statement in the Row Source in the form.
SELECT [ShipLine].[ShipLineID], [ShipLine].[ShipLineName] FROM ShipLine ORDER
BY [ShipLineName];
Not sure if the helps.
Thanks for you prompt response.
Gilc

Jeff said:
I'll take a wild stab and ask if the data field (in the table) underlying
[cboAsiaNoticeShipLine] is set up as a "Lookup" data type? That data type
displays one thing (e.g., "FE Evergreen"), but is actually storing something
else (the primary key of the record containing that looked up value).

Regards

Jeff Boyce
Microsoft Office/Access MVP
Can anyone find a reason why this IF Statement only returns a "N/A".
To the best of my ability I have confirmed that all the data in the
[quoted text clipped - 30 lines]
End If
End Sub
 
J

Jeff Boyce

My guess is that the code in your IF() statement is "falling through" to the
"else" condition, resulting in "N/A".

If this were mine, I'd add in a breakpoint just before the IF() statement
and use that to "step through" the code, determining what value
[cboAsiaNoticeShipLine] actually holds (vs. what you thought it held).

By the way, if your 'source' query is what you are filling the combobox
with, the "value" of the first item is NOT the text (what is displayed), but
the ShipLineID.

Regards

Jeff Boyce
Microsoft Office/Access MVP


gchichester via AccessMonster.com said:
Jeff,
I checked the AsiaNoticeShipLine in table design and Lookup tab is set to
textbox.
But I did find this statement in the Row Source in the form.
SELECT [ShipLine].[ShipLineID], [ShipLine].[ShipLineName] FROM ShipLine
ORDER
BY [ShipLineName];
Not sure if the helps.
Thanks for you prompt response.
Gilc

Jeff said:
I'll take a wild stab and ask if the data field (in the table) underlying
[cboAsiaNoticeShipLine] is set up as a "Lookup" data type? That data type
displays one thing (e.g., "FE Evergreen"), but is actually storing
something
else (the primary key of the record containing that looked up value).

Regards

Jeff Boyce
Microsoft Office/Access MVP
Can anyone find a reason why this IF Statement only returns a "N/A".
To the best of my ability I have confirmed that all the data in the
[quoted text clipped - 30 lines]
End If
End Sub
 
R

Ron2006

What are the field lengths and what is the bound column for that combo
box or list box?
 
G

gchichester via AccessMonster.com

Jeff,
You nailed it - the source was using the ShipLineID, once I changed it the
the name
it works correctly .

Thank again for you input.
Gil



Jeff said:
My guess is that the code in your IF() statement is "falling through" to the
"else" condition, resulting in "N/A".

If this were mine, I'd add in a breakpoint just before the IF() statement
and use that to "step through" the code, determining what value
[cboAsiaNoticeShipLine] actually holds (vs. what you thought it held).

By the way, if your 'source' query is what you are filling the combobox
with, the "value" of the first item is NOT the text (what is displayed), but
the ShipLineID.

Regards

Jeff Boyce
Microsoft Office/Access MVP
Jeff,
I checked the AsiaNoticeShipLine in table design and Lookup tab is set to
[quoted text clipped - 23 lines]
 

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

Similar Threads


Top