Vous êtes sur la page 1sur 11

Data Grid in Macros

MIS) 24 Jun 09 3:33 I am using macros to perform certain tasks within Accpac.My problem is that on certain machines the data grid is being"eaten up" by the machine so then where the is a grid the macro debugs.Who knows what could be wrong? 24 Jun 09 5:13 tuba2007 (Programmer) Make sure the control has been registered on every machine. ettienne (TechnicalUser) MS Flexgrid? 24 Jun 09 7:04

Kivairu (MIS) 24 Jun 09 7:20 What control? tuba2007 (Programmer) 24 Jun 09 7:23 The data grid control you're using on your form, i.e., MSFlexGrid. tuba2007 (Programmer) 24 Jun 09 7:24 More info here: http://www.pcreview.co.uk/forums/thread-3: Infoconnect through Gauntlet Firewall740392.php

ettienne (TechnicalUser) Simple fix for MSFlexGrid is to add this line of code to MainSub() in your macro:

24 Jun 09 8:06

CreateObject("WScript.Shell").RegWrite "HKLM\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{6262D3A0-531B-11CF-91F6-C2863C385E30}\Compatibility Flags", 0, "REG_DWORD"

DjangMan (Programmer) That's worth a * to me.

24 Jun 09 8:14

Norming Asset Management Macros


23 Jun 06 15:00 I am using Norming Asset Management as a Fixed Assets module in Accpac 5.3. Macros don't seem to record in this module. I am trying to write code to allow for an Acquisition Batch Entry. I am using the GL Batch Entry code that I have as a guide and I am tweaking accordingly. Nothing seems to work. I can create a new batch but can't populate any of the batch header fields such as "descritpion". If I can't record macros in this module, is it possible that VBA code doesn't work in this area? Thanks, Mike jayconverse (MIS) Most third-party products don't record. Use RVSPY to figure out how they do it. Jay Converse IT Director Systemlink, Inc. mdewis (TechnicalUser) Thanks Jay. What is RVSPY? jayconverse (MIS) Look in Accpac/Tools. Jay Converse IT Director Systemlink, Inc. ettienne (TechnicalUser) mdewis (TechnicalUser)

23 Jun 06 15:50

23 Jun 06 15:51 23 Jun 06 15:55

23 Jun 06 17:05 When 3rd party developers write their software in the SDK they need to enable macro recording for their modules, not all are aware of this and it is a small thing to do, kinda pee's me off when they do not enable macro recording. mdewis (TechnicalUser) 23 Jun 06 17:07 Thanks. If anyone has any examples of creating an Asset Management Acquisition Batch via vba code, it would be greatly appreciated. Thanks, Mike DjangMan (Programmer)

26 Jun 06 10:31 You might have more success sending an e-mail directly to Norming and ask them for an example.

Are you trying to read information from Norming or write information to the Norming tables? If you are only reading then don't bother with the views - just use ODBC. You'll have much faster performance that way. If you are writing data then I would strongly encourage you to use the views to avoid messing up the database. Regards, Django mdewis (TechnicalUser) Thanks. I am actually looking to write data...ie create the ability to use an excel file to populate an Acquisition Batch Entry. It seems like it is missing the File...Import feature that is available on most other Accpac modules. We don't use the ODBC feature here so I would have to go the views route. RVSPY seems pretty involved, messy and complicated but if that is the route I should go, assuming I can't get Norming to send me anything, that is what I'll do. Again, if anyone has had any luck with creating a batch entry macro for Norming Asset Management, I would greatly appreciate seeing the code. Thanks, Mike ettienne (TechnicalUser) Are you trying to take on assets, or is this something you will be doing on a regular basis? mdewis (TechnicalUser)

26 Jun 06 10:40

26 Jun 06 12:26

26 Jun 06 12:32 This would be to replace the process of manually entering a batch from a list of invoices on a monthly basis. I know that you can import in additions into the Asset Register but this doesn't produce an Acquistion Batch in Asset Manager. It only adds the assets into your register and then calculates depreciation on the new balance. I want to have an Acquisition Batch Entry created. Mike ettienne (TechnicalUser)

26 Jun 06 15:56 A word of advise: Excel is the worst to use for data entry by users. There is no data validation in the "fields" and users tend to enter garbage which will cause you much pain. Why reinvent the wheel? There is a batch entry screen, let them use it. mdewis (TechnicalUser) 26 Jun 06 16:01 The Excel File would be an export from another system. It would be a starting step and then I would look to directly interface between the other system and Asset Manager. Mike mdewis (TechnicalUser)

28 Jun 06 17:03

Miraculously, I was able to get a little further in this process by using RVSPY. I am attempting to replicate a GL Batch Entry using VBA for a Norming Acquisition Entry. I am able to update the Batch Number and Batch Description, however, I keep getting errors when I try to update the Acquisition Batch Detail. The error I get is "Attempt to modify a different record than was retrieved". I suspect this is an error that you can see in other areas as well such as w/ GL Batches. Does anyone know a quick solution to this? I have a feeling I am not updating / inserting / init in the right place. I'll send my code if more detail is required. Much Appreciated, Mike mdewis (TechnicalUser)

4 Jul 06 10:39 Can anyone help w/ this? I can create a batch and can add lines of detail to the batch but only if the first line has already been entered. That is, I can only add lines to the batch detail after there is one line of data already entered. I suspect I have my updates and inserts in the wrong place or I have forgotten something like an "init". Here is the code: On Error GoTo ACCPACErrorHandler Dim objExcel Dim objWorkBook Set objExcel = CreateObject("EXCEL.APPLICATION") Set objWorkBook = objExcel.Workbooks.Open("s:\Accpac Macros Do Not Delete\StillTesting\ASSET MANAGER TEST.xls") Set objworksheets = objWorkBook.Worksheets Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink Set mDBLinkCmpRW = OpenDBLink(DBLINK_COMPANY, DBLINK_FLG_READWRITE) Dim mDBLinkSysRW As AccpacCOMAPI.AccpacDBLink Set mDBLinkSysRW = OpenDBLink(DBLINK_SYSTEM, DBLINK_FLG_READWRITE) Dim temp As Boolean Dim AM1Batch As AccpacCOMAPI.AccpacView Dim AM1BatchFields As AccpacCOMAPI.AccpacViewFields mDBLinkCmpRW.OpenView "AM0001", AM1Batch Set AM1BatchFields = AM1Batch.Fields Dim AM2Detail As AccpacCOMAPI.AccpacView Dim AM2DetailFields As AccpacCOMAPI.AccpacViewFields mDBLinkCmpRW.OpenView "AM0002", AM2Detail Set AM2DetailFields = AM2Detail.Fields AM1Batch.Compose Array(AM2Detail) AM1Batch.Browse "(ACQHID = " & InputBox("Enter Batch Number") & ")", True

Do While AM1Batch.Fetch Loop AM2Detail.Read AM2Detail.Fetch For Each cell In objworksheets("Sheet1").range("a2:a5") AM2Detail.Insert AM2Detail.Fields("ASSETNO").Value = cell.Value AM2Detail.Fields("ASSETDesc").Value = cell.offset(0, 1).Value AM2Detail.Fields("GROUP").Value = cell.offset(0, 2).Value AM2Detail.Fields("AQUCODE").Value = cell.offset(0, 3).Value AM2Detail.Fields("ACCSET").Value = AM2Detail.Fields("COSTCENT").Value AM2Detail.Fields("BKMETHOD").Value = cell.offset(0, 4).Value AM2Detail.Fields("BKPERDID").Value = cell.offset(0, 5).Value AM2Detail.Fields("BKESTY").Value = cell.offset(0, 9).Value AM2Detail.Fields("BKVALUE").Value = cell.offset(0, 10).Value AM2Detail.Update Next cell AM1Batch.Update Exit Sub jayconverse (MIS) Why are you .Reading and .Fetching AM2Detail? You should just .Init and .Insert. Jay Converse IT Director Systemlink, Inc.

4 Jul 06 18:48

enter comment in PO with macro


johnhugh (TechnicalUser) 23 May 11 21:42

Hi, I'm trying to write a macro for entering a PO line item comment but can't work out the error I get. I've taken the code from a macro recording. The error i get is: Method 'PutWithoutVerification' of object 'IAccpacViewField' failed.
CODE

Private Sub cmdSearch_Click() Dim temp As Boolean Dim POPOR1header As AccpacCOMAPI.AccpacView Dim POPOR1headerFields As AccpacCOMAPI.AccpacViewFields mDBLinkCmpRW.OpenView "PO0620", POPOR1header Set POPOR1headerFields = POPOR1header.Fields Dim POPOR1detail1 As AccpacCOMAPI.AccpacView Dim POPOR1detail1Fields As AccpacCOMAPI.AccpacViewFields mDBLinkCmpRW.OpenView "PO0630", POPOR1detail1 Set POPOR1detail1Fields = POPOR1detail1.Fields Dim POPOR1detail2 As AccpacCOMAPI.AccpacView Dim POPOR1detail2Fields As AccpacCOMAPI.AccpacViewFields mDBLinkCmpRW.OpenView "PO0610", POPOR1detail2 Set POPOR1detail2Fields = POPOR1detail2.Fields Dim POPOR1detail3 As AccpacCOMAPI.AccpacView Dim POPOR1detail3Fields As AccpacCOMAPI.AccpacViewFields mDBLinkCmpRW.OpenView "PO0632", POPOR1detail3 Set POPOR1detail3Fields = POPOR1detail3.Fields Dim POPOR1detail4 As AccpacCOMAPI.AccpacView Dim POPOR1detail4Fields As AccpacCOMAPI.AccpacViewFields mDBLinkCmpRW.OpenView "PO0619", POPOR1detail4 Set POPOR1detail4Fields = POPOR1detail4.Fields Dim POPOR1detail5 As AccpacCOMAPI.AccpacView Dim POPOR1detail5Fields As AccpacCOMAPI.AccpacViewFields mDBLinkCmpRW.OpenView "PO0623", POPOR1detail5 Set POPOR1detail5Fields = POPOR1detail5.Fields Dim POPOR1detail6 As AccpacCOMAPI.AccpacView Dim POPOR1detail6Fields As AccpacCOMAPI.AccpacViewFields mDBLinkCmpRW.OpenView "PO0633", POPOR1detail6 Set POPOR1detail6Fields = POPOR1detail6.Fields POPOR1header.Compose Array(POPOR1detail2, POPOR1detail1, POPOR1detail3, POPOR1detail4, POPOR1detail5) POPOR1detail1.Compose Array(POPOR1header, POPOR1detail2, POPOR1detail4,

Nothing, Nothing, POPOR1detail6) POPOR1detail2.Compose Array(POPOR1header, POPOR1detail1) POPOR1detail3.Compose Array(POPOR1header, POPOR1detail4) POPOR1detail4.Compose Array(POPOR1header, POPOR1detail2, POPOR1detail1, POPOR1detail3) POPOR1detail5.Compose Array(POPOR1header) POPOR1detail6.Compose Array(POPOR1detail1)

POPOR1headerFields("PONUMBER").Value = "PO-0024100" Purchase Order Number temp = POPOR1header.Exists POPOR1header.Read temp = POPOR1detail3.Exists POPOR1detail3.Init POPOR1detail3Fields("PORRREV").PutWithoutVerification ("999999999999999999") ' Line Number POPOR1detail3.Browse "", 1 POPOR1detail3.Fetch temp = POPOR1detail2.Exists POPOR1detail2.Init POPOR1detail2Fields("PORCREV").PutWithoutVerification ("999999999999999999") ' Comment Identifier POPOR1detail2.Browse "", 1 POPOR1detail2.Fetch POPOR1detail2.Browse "(COMMENTTYP = ""1"")", 1 temp = POPOR1detail2.Exists POPOR1detail2.RecordClear temp = POPOR1detail2.Exists POPOR1detail2.RecordCreate 0 POPOR1detail2.Process POPOR1detail2Fields("COMMENT").PutWithoutVerification ("test") Comments/Instructions POPOR1detail2.Insert End Sub tuba2007 (Programmer)

'

'

23 May 11 21:52

Get rid of all the "temp =" lines, and the PORRREV and PORCREV lines, they're just noise. johnhugh (TechnicalUser) 23 May 11 22:08

Thanks tuba. I've done that now. My code fails at this line [code] POPOR1detail2Fields("COMMENT").PutWithoutVerification ("test") [\code] tuba2007 (Programmer)

' Comments/Instructions

23 May 11 22:11

What's the text in the Session.Errors object? johnhugh (TechnicalUser) 23 May 11 22:33

It says "Attempt to change read-only field "Comments/Instructions" Would this have something to do with having Purchasing Workflow installed? tuba2007 (Programmer) 23 May 11 22:57

Maybe. I've never done macros with that module installed, only straight PO. PW definitely subclasses PO views. DjangMan (Programmer) 24 May 11 7:06

When you recorded the macro did you create a new PO or did you select an existing PO to modify? If you selected an existing PO - was that line complete, by chance? johnhugh (TechnicalUser) 24 May 11 8:26

I selected an existing PO but the line wasn't complete. DjangMan (Programmer) 24 May 11 8:39

Make sure that you've navigated to the detail line that you want to add the comment to. Here's a chunk of code that I use:
CODE

With POOrderDetailComment .RecordClear .Fields("PORCREV").PutWithoutVerification LastPODetailCommentLine .RecordCreate VIEW_RECORD_CREATE_DELAYKEY .Fields("COMMENT").PutWithoutVerification aText .Insert LastPODetailCommentLine = .Fields("PORCREV").Value

End With POOrderDetail.Fields("HASCOMMENT").Value = 1 johnhugh (TechnicalUser)

24 May 11 10:28

Thanks Djangman, I tried your code but still get the same error message: "Attempt to change read-only field "Comments/Instructions" Does your macro work on a system that has purchasing workflow installed? It very odd, I can enter a comment through the normal PO screen but the macro returns an error. Also, do you not have to define whether it is a comment or an instruction?
CODE

POPOR2detail2Fields("COMMENTTYP").Value = "1" 'comment

DjangMan (Programmer)

24 May 11 10:41

It will default to a comment type line so I don't specify it. I'm not running the workflow product. The only thing I can suggest is running your macro on a set of sample data that doesn't have workflow activated. You might also have to contact Pacific Technologies for assistance. johnhugh (TechnicalUser) 14 Jun 11 11:16

Hi DjangMan, I managed to enter a PO comment, however I fail to determine the last comment line and thus my comments are always added on the top, not the bottom. In my code below I navigate to the PO and line comment. In the comment section, I start from the bottom line which is an instruction. To find the last comment I try to go backwards till I find the last 'COMMENTTYP=1' My 'Loop While POPOR2detail2.GoPrev' does not seem to work though. It just enters an endless loop never going backwards through the comments. What am I doing wrong?

CODE

'PO header

POPOR2header.GoBottom Do If POPOR2headerFields("PONUMBER") = "PO-0024087" Then Exit Do End If Loop While POPOR2header.GoPrev 'PO line details POPOR2detail1.GoBottom Do 'Get Details If POPOR2headerFields("PORHSEQ") = POPOR2detail1Fields("PORHSEQ") Then Exit Do End If Loop While POPOR2detail1.GoPrev 'comments 'find last comment line POPOR2detail2.GoBottom Do If POPOR2detail1Fields("PORCSEQ") <> POPOR2detail2Fields("PORCSEQ") Then Exit Do End If If POPOR2detail2.Fields("COMMENTTYP") = 1 Then LastPODetailCommentLine = POPOR2detail2.Fields("PORCREV") POPOR2detail2.RecordClear POPOR2detail2.Fields("PORCREV").PutWithoutVerification LastPODetailCommentLine POPOR2detail2.RecordCreate VIEW_RECORD_CREATE_DELAYKEY POPOR2detail2Fields("COMMENT").PutWithoutVerification ("test5") ' Comments/Instructions POPOR2detail2.Insert End If Loop While POPOR2detail2.GoPrev POPOR2detail1Fields("HASCOMMENT").Value = 1 'update line item POPOR2header.Update DjangMan (Programmer)

14 Jun 11 12:04

It looks like you're reading the last number and then replacing it with the last number.
CODE

LastPODetailCommentLine = POPOR2detail2.Fields("PORCREV") POPOR2detail2.RecordClear POPOR2detail2.Fields("PORCREV").PutWithoutVerification LastPODetailCommentLine The view's revision list will insert the record below the one that you supply the key value for. So you want to get the last value for PORCREV for that detail line and use that in your code. Something like:
CODE

With POOrderDetailComment .Browse "", True '<- just make sure this only browses your current detail line's comments if .GoBottom then

LastPODetailCommentLine = .Fields("PORCREV").Value else LastPODetailCommentLine = -1 end if end with With POOrderDetailComment .RecordClear .Fields("PORCREV").PutWithoutVerification LastPODetailCommentLine .RecordCreate VIEW_RECORD_CREATE_DELAYKEY .Fields("COMMENT").PutWithoutVerification aText .Insert LastPODetailCommentLine = .Fields("PORCREV").Value End With

johnhugh (TechnicalUser)

15 Jun 11 6:13

Thank you.

Vous aimerez peut-être aussi