I am currently getting the Clarion 6.3 error: Field not found: SETFILTER
The code is located in the ApplyFilter section which is part of the ObjectABC template code below:
If g:InstallerIsRegional = 1
localVar:ItemCode = IWIE:InvItemCode !Store itemCode from view
GetRegionalItemPrice(localVar:ItemCode ) !Proc to check if Itemcode to be included in browse.
End
INVWIMEX.SetFilter('IWIE:InvItemCode[1]='''&localVar:ItemCode[1]&'''')
INVWIMEX.ApplyFilter
INVWIMEX.Next()
Looks like some unbalanced quotes.
Try this:
strFilter = 'IWIE:InvItemCode[1]=<39>' & localVar:ItemCode[1] &'<39>'
INVWIMEX.SetFilter(strFilter)
PS: add this to the data section: strFilter string(255)
Related
I'm trying to import an Excel to Access DB, and some customer numbers cannot be imported due to Type Conversion Failure. It is 12 entries out of 66 thousand. Normally the customer number is a number, but these 12 are strings like ABCDEFT001. I tried setting the field of the table to Long Text or Short text, they are still not imported (only to ImportError table). Do you know what else I can try?
Thank you very much in advance!
P.S. I'm trying to import using DoCmd.TransferSpreadsheet
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "Inv level", "Path/to/file.xlsb", True, "Sheetname!"
This strategy links to the excel file, instead of directly importing it, and then selects data out of it and casts any fields that need it to the correct datatype.
Sub ImportFromExcel()
Dim pathToFile As String
Dim targetTableName As String
Dim sql As String
pathToFile = "C:\Path\To\File.xlsx"
targetTableName = "ImportResults"
'//create the link
DoCmd.TransferSpreadsheet acLink, _
acSpreadsheetTypeExcel12, _
targetTableName, _
pathToFile, _
True '//This part only if the excel file has field headers
'//import
sql = "SELECT Field1Name, CStr(CustNumber) AS CustNumber, Field3Name INTO NewImportTable FROM " & targetTableName
CurrentDb.Execute sql
'//remove the link
DoCmd.DeleteObject acTable, targetTableName
End Sub
***Two pitfalls of this code to be aware of:
1) You should delete any table with the name "NewImportTable" before running this code, or you'll get a "Table Already Exists" error.
2) If any errors happen in this Sub before you remove the link, you'll have an issue the next time it runs, as it will create a link called "ImportResults1" since "ImportResults" would still exist. The really scary thing is that no errors would be thrown here. It would create "ImportResults1" and then run your sql on "ImportResults"!!
Hi I have a macro that creates multiple sheets and has Name, Number, Sheet Category. The last being my own project parameter.
I can successfully create the sheets with name and number but I am having difficulty adding the value from CSV file to the project parameter "SD_Sheet Category". Below are some code grabs to help explain.
Public Module mSheetCreator
Public Structure structSheet
Public sheetNum As String
Public sheetName As String
Public sortCategory As String
End Structure
Then I have a function that reads the CSV file and does the following:
Try
currentRow = MyReader.ReadFields()
'create temp sheet
Dim curSheet As New structSheet
curSheet.sheetNum = currentRow(0)
cursheet.sheetName = currentRow(1)
curSheet.sortCategory = currentRow(4)
'add sheet to list
sheetList.Add(curSheet)
Then I have a transaction that does the following:
For Each curSheet As structSheet In sheetList
Try
If sheetType = "Placeholder Sheet" Then
m_vs = ViewSheet.CreatePlaceholder(curDoc)
Else
m_vs = ViewSheet.Create(curDoc, tblock.Id)
m_vs.Parameter("SD_Sheet Category").Set(CStr(curSheet.sortCategory))
End If
m_vs.Name = curSheet.sheetName
m_vs.SheetNumber = curSheet.sheetNum
The problem is this code:
m_vs.Parameter("SD_Sheet Category").Set(CStr(curSheet.sortCategory))
I am getting a warning that says it's an "implicit conversion from 'String' to 'Autodesk.Revit.DB.BuiltInParameter'"
once I build solution
When I run the code in Revit it produces an error saying
"Conversion from string 'SD_Sheet Category" to type 'Integer' is not valid"
It creates the sheets but disregards all the info in the CSV file. I know the rest of the code works as I have removed this particular line of code so I know it isn't the problem
Any suggestions??
I believe that as of a particular version of Revit API you cannot use .Parameter(“name”)
Because there might be two parameters with the same name.
So you need to do something more like
Dim cat as Parameter
Cat = m_vs.GetParameters(“sd_sheet category”).First()
Cat.Set(CSTR(cursht.sortCategory))
Good luck!
I`m working on a VBA macro in Excel, to gather information from a CNC program code.
So far, I have gotten Material type, thickness, x & Y sizes, and qty used.
I`m trying to get the 'cutting length' now - so I can use it in costing calculations.
Here is the XML code segment :
<Info num="6" name="Tools">
<MC machine="psys_ETN_5">
<Tool name="TN901" length="16262.96209" time="53.72817301" cutoutArea="8138.657052"/>
</MC>
</Info>
There are lots of 'Info' lines.
There may be more than one 'Tool' line, but I`m only after anything from line with 'TN901'.
The data I`m trying to capture is the value of 'Length="######.##"'
I`ve captured everything else I need from code like this :
<Material>316</Material>
<SheetX>2000</SheetX>
<SheetY>1000</SheetY>
<Thickness>3</Thickness>
</Material>
using code like this:
For Each nodemat In XMLDataDrg.SelectNodes("//Material")
Matl = nodemat.Text
Worksheets("Sheet4").Range("H" & RowA).Value = Matl
Next
For Each nodesht In XMLDataDrg.SelectNodes("//Thickness")
Thk = nodesht.Text
Worksheets("Sheet4").Range("I" & RowA).Value = Thk
Next
But that type of code does not get the cutting length.
Any help please ? :)
Thanks
Simon
Thickness is saved as XML element in your example.
The length is stored as an XML attribute.
(see https://www.xmlfiles.com/xml/xml-attributes/)
To read an XML attribute please have a look at:
Read XML Attribute VBA
Based on the code presented there you should be able to solve your issue with:
'Include a reference to Microsoft XML v3
Dim XMLDataDrg As DOMDocument30
Set XMLDataDrg = New DOMDocument30
XMLDataDrg.Load ("C:\...\sample.xml")
'...
Dim id As String
id = XMLDataDrg.SelectSingleNode("//Info/MC/Tool").Attributes.getNamedItem("length").Text
You can use an xpath to restrict to Tool elements with attribute name having value TN901 then loop all the attributes and write out. I am reading your XML from a file on desktop.
Option Explicit
Public Sub test()
Dim xmlDoc As Object
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
With xmlDoc
.validateOnParse = True
.setProperty "SelectionLanguage", "XPath"
.async = False
If Not .Load("C:\Users\User\Desktop\Test.xml") Then
Err.Raise .parseError.ErrorCode, , .parseError.reason
End If
End With
Dim elem As Object, attrib As Object
For Each elem In xmlDoc.SelectNodes("//Tool[#name='TN901']")
For Each attrib In elem.Attributes
Debug.Print attrib.nodeName, attrib.Text
Next
Next
End Sub
Result:
I'm trying to import a semi colon delimited .csv file into an access database using the following code. I've set up an import specification which works called "Import-FACTS". and VBA can see the specification (by putting OLEacc.CurrentProject.ImportExportSpecifications(0) into the watch window.
Sub ImportFacts()
Dim OLEacc As Access.Application
Set OLEacc = GetObject("", "Access.Application")
OLEacc.OpenCurrentDatabase (ThisWorkbook.Path & "\" & "LargeData.accdb")
OLEacc.DoCmd.TransferText TransferType:=acImportDelim, _
SpecificationName:="Import-FACTS",_
TableName:="Facts",_
Filename:=ThisWorkbook.Path & "\Facts.csv",_
HasFieldNames:=False
End Sub
However I get the debug message:
Run-time error '3625' The text file specification "Import-Facts" does
not exist You cannot import export or link using the specification.
Any ideas?
Important note for imports
There is a problem with the text file specification as the name may not be the same that is displayed when you check your saved imports.
To know the true name, run the following SQL:
SELECT MSysIMEXSpecs.SpecName,
MSysIMEXColumns.FieldName,
MSysIMEXColumns.Start,
MSysIMEXColumns.Width,
MSysIMEXColumns.SkipColumn
FROM MSysIMEXColumns INNER JOIN
MSysIMEXSpecs ON MSysIMEXColumns.SpecID = MSysIMEXSpecs.SpecID
ORDER BY MSysIMEXSpecs.SpecName,
MSysIMEXColumns.Start,
MSysIMEXColumns.Width;
The SpecName field contains the right name you are looking for!
I have two lines of code that seems extremely easy, but excel keeps giving me this Compile error telling me that object is required?
So basically I want to get the current time, and replace the spaces with underscores so I can use this string as the name of my log fime.
Dim name As String
'EXCEL GIVE ME compile error: object required
name = Replace(FormatDateTime(Now, DateFormat.LONGTIME), " ", "_")
What's wrong?!!
Replacing DateFormat.LONGTIME to 'vbLongTime' works for me.
name = Replace(FormatDateTime(Now, vbLongTime), " ", "_")
You need to invoke Now as it is not a variable but a procedure
var now = str(Now());
name = Replace(FormatDateTime(now, DateFormat.LONGTIME), " ", "_")
should fix it