Skip to main content
Solved

"Conversion failed when converting the varchar value to data type int." error

  • March 22, 2023
  • 5 replies
  • 1503 views
  • Translate All

Forum|alt.badge.img+1

I am trying to build a GI using the INItemSite table to display the InventoryID and the MinQty designated for each warehouse. I’m trying to use the following formula to limit to the MinQty from a specific warehouse and will duplicate several times for each warehouse (grouping the results by InventoryID):

=IIf([INItemSite.SiteID]='Warehouse-01',[INItemSite.MinQty],0)

However, when I try to view the results I receive the following error message:

Conversion failed when converting the varchar value 'Warehouse-01' to data type int.

 

Anyone have any suggestions around this? I would imagine this error means the INItemSite.SiteID field does not actually contain the text data but is actually a numeric value assigned to that SiteID, but I can’t figure out how to fix this GI. Seems fairly straightforward.

Best answer by lauraj46

Hi @mikeho ,

The Site field is an integer.  If you need to reference the human readable code, add INSite to your GI and use INSite.SiteCD in your formula.

Laura 

View original

5 replies

lauraj46
Captain II
Forum|alt.badge.img+9
  • Captain II
  • Answer
  • March 23, 2023

Hi @mikeho ,

The Site field is an integer.  If you need to reference the human readable code, add INSite to your GI and use INSite.SiteCD in your formula.

Laura 

Translate

Naveen Boga
Captain II
Forum|alt.badge.img+20

@mikeho  As indicated by Laura, you can join the INSite with INItemSite with SiteID field.

 and check like below

 

IIf([INSite.SiteCD]='Warehouse-01',[INItemSite.MinQty],0)
Translate

Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • March 23, 2023

Thank you @lauraj46 and @Naveen Boga! Now to throw a larger wrench into the works…

I need to start from a list of all the inventory items (InventoryItem table) and was going to connect the INItemSite table to that table via the InventoryID field. However, it would seem that the INSite table would need to sit in between these two tables, but I can’t figure out the best way to do this. Any suggestions?

Translate

lauraj46
Captain II
Forum|alt.badge.img+9
  • Captain II
  • March 23, 2023

Hi @mikeho ,

No need for it to go in the middle, you should be able to join InventoryItem --> InItemSite and  InItemSite -->INSite.

Hope that helps!

Laura

Translate

Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • March 23, 2023

Guess I was just making it more complicated than it needed to be. Thanks, @lauraj46! That worked fine.

Translate