Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating ICPRIC (Sale Pricing)

Status
Not open for further replies.

Bluejay07

Programmer
Mar 9, 2007
780
CA
I am encountering a problem trying to update ICPRIC.

I am using VB6 and Accpac 5.4.
The problem exists directly after the .read statement. The values being passed to the fields are not being accepted and testing only shows the default value.

Code:
Dim ICPRIC As AccpacCOMAPI.AccpacView
Dim ICPRTX As AccpacCOMAPI.AccpacView
Dim ICPRICC As AccpacCOMAPI.AccpacView
Dim ICPRICP As AccpacCOMAPI.AccpacView
Dim i As Integer
   
On Error GoTo ERR_Handler
   
CISDBLink.OpenView "IC0480", ICPRIC
CISDBLink.OpenView "IC0490", ICPRTX
CISDBLink.OpenView "IC0481", ICPRICC
CISDBLink.OpenView "IC0482", ICPRICP

'N=Nothing for shortened code in this post   
ICPRIC.Compose Array(ICPRTX, N, N, N, N, N, ICPRICC, ICPRICP, N, N, N)
ICPRTX.Compose Array(ICPRIC, N, N)
ICPRICC.Compose Array(ICPRIC)
ICPRICP.Compose Array(ICPRIC, N)

'// Customer information.
With ICPRIC          
  .Fields("ITEMNO").Value = flgItem.TextMatrix(pRowNum, 0)
      
  For i = 1 To UBound(m_strPLCode, 2)    '// 2 is for a two dimensional array.
    .Fields("PRICELIST").Value = m_strPLCode(pRowNum, i)
         
    If Trim$(m_strPLCode(pRowNum, i)) <> "" Then
       If .Read Then             
          .Fields("DSALEPRICE").Value = flgItem.TextMatrix(pRowNum, 1)
          .Fields("DSALESTART").Value = DateSerial(Year(flgItem.TextMatrix(pRowNum, 2)), Month(flgItem.TextMatrix(pRowNum, 2)), Day(flgItem.TextMatrix(pRowNum, 2)))
          .Fields("DSALEEND").Value = flgItem.TextMatrix(pRowNum, 3)
          .Update
          .Post
       Else
          MsgBox "Item number " & flgItem.TextMatrix(pRowNum, 0) & " with price list code " & .Fields("PRICELIST") & " does not exist.", vbOKOnly + vbExclamation + vbApplicationModal + vbDefaultButton1, "Cannot Find Item"
       End If
    End If
         
  Next i
  .Close
End With
   
Set ICPRIC = Nothing
Set ICPRTX = Nothing
Set ICPRICC = Nothing
Set ICPRICP = Nothing
Exit Function

I have run a macro and have tried various combinations of .init, .putwithoutverification, .read, .browse/.fetch and its all the same result. After .read section, the passed values are not stored before the update.

Any help would be greatly appreciated.
 
1. Record a macro to see how Accpac does it.
2. You left off CURRENCY, it's a key field.
 
Hi tuba2007,

I have run a macro, and duplicated the code. No Luck.
In addition, I have added the CURRENCY, and still hasn't helped.

I will re-examine the macro in case I missed something else.
 
I re-examined the macro. I added the .Order = 2 and .init, but still did not make any difference.

Once the .read is executed, the remaining fields do not save the passed values.

I get the following results before executing the .update.

.fields("DSALEPRICE") = 0
.fields("DSALESTART") = ""
.fields("DSALEEND") =
 
As mentioned in my first post, I tried that as well. The result is the same.

Here is the statement used:
.Browse "CURRENCY = CAD AND PRICELIST = " & m_strPLCode(pRowNum, i) & " AND ITEMNO = " & flgItem.TextMatrix(pRowNum, 0), True

After .fetch, .fields("DSALEPRICE") = 0 and the others remain null.

I have also verified that the values being passed are valid.
 
Does the user you are logging in as have rights to change prices?
 
Hi ettienne,

I am logged on using the Admin user.
I have also restarted my computer.

I have also tested with an active and an inactive item. It's all the same result.
 
Currency, Pricelist, ItemNo are text fields so your browse will need to surround the values in quotes. Item Number will be unformatted.

In your recorded macro do you see the updated values in those fields before the .update is executed.
 
You may need a .Process in there. Here's a snip of some code I've had running for years:

ICNewPriceHeader.Cancel
ICNewPriceHeader.Init
ICNewPriceHeader.Fields("ITEMNO").PutWithoutVerification (sNewItem)
ICNewPriceHeader.Fields("PRICELIST").Value = "DFT"
ICNewPriceDetail.Fields("CURRENCY").Value = "USD"
ICNewPriceDetail.Fields("PRICELIST").Value = "DFT"
ICNewPriceDetail.Fields("ITEMNO").Value = sNewItem

ICNewPriceHeader.Process
ICNewPriceHeader.Fields("DBASEPRICE") = recInput.nPrice
ICNewPriceHeader.Insert
ICNewPriceHeader.Post
 
DjandMan:
Thank you for your post. I will verify my browse statement.
The macro showed the following:

Code:
ICPRIC_T1headerFields("DSALEPRICE").Value = "2.000000"                ' Sale Price
ICPRIC_T1headerFields("DSALESTART").Value = DateSerial(2008, 10, 9)   ' Sale Start Date
ICPRIC_T1headerFields("DSALEEND").Value = DateSerial(2008, 10, 10)    ' Sale End Date

ICPRIC_T1header.Update
ICPRIC_T1header.Post

Tuba2007:
Thank you for your suggestion. I will try it.


I have made some progress. I appears that I need the sale unit of measure, even though it did not appear in the macro.
I am now able to update the very first price list code for the item, however, all other price list codes remain unchanged during the loop. My current code, I have changed back to the .read instead of the .browse/.fetch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top