
- ArcObjects-
- 07-18-2007
If you were Registered and logged in, you could reply and use other advanced thread options
Ok, writing a tool that lets end-user apply weightings (via slider
bars) which in turn changes the attributes (calculates new values).
Thats fine. What Id like to do is SAVE the weighting factors applied
into a stand-alone table so that they can be recalled next time the
session is opened.
Now, im fairly new to VBA but the code below is nearly there - A user
can move slider bars (in code below, only one weighting is there for
testing purposes) which populates the variable EcS1_Wf
This is then written to the stand-alone table (WeightFactors).
However, it creates a new record everytime - I only need there to be
one record in the table (i.e. the Last sessions weightings)
How would you tweak the code to apply this?
Do you delete the row out at the beginning? Or change it so that
instead of inserting a new row, it updates a row?
Either way, bit stuck on how to change code. Any tips would be
nice...
Dim pWorkspaceFactory As IWorkspaceFactory
Dim pFeatWorkspace As IFeatureWorkspace
Set pWorkspaceFactory = New AccessWorkspaceFactory
Set pFeatWorkspace = pWorkspaceFactory.OpenFromFile(strDBpath, 0)
Set pWtFacTable = pFeatWorkspace.OpenTable("WeightFactors")
'Create a query filter to select row
Dim pQf As IQueryFilter
Set pQf = New QueryFilter
Dim pFcursor1 As ICursor
Set pFcursor1 = pWtFacTable.Search(Nothing, False)
'Get the rows that match the query filter
Dim pRow As IRow
Set pRow = pFcursor1.NextRow
If pRow Is Nothing Then
MsgBox "Please check format of weighting tables - process exiting !"
Exit Sub
Else
' Writing selected weighting factors to table
Dim pWgtInsCursor As ICursor
Set pWgtInsCursor = pWtFacTable.Insert(False)
Dim pWgtRowBuff As IRowBuffer
'Find fields
EcS1Wf_db = pWtFacTable.FindField("EC1_WSF")
'Write Fields to table
Set pWgtRowBuff = pWtFacTable.CreateRowBuffer
With pWgtRowBuff
.Value(EcS1Wf_db) = Me!EcS1_Wf.Value
End With
pWgtInsCursor.InsertRow pWgtRowBuff
End If
MsgBox "Finished Calculations", vbInformation
Set pMxDoc = ThisDocument
pMxDoc.ActiveView.Refresh
frmWtgs.Hide
bars) which in turn changes the attributes (calculates new values).
Thats fine. What Id like to do is SAVE the weighting factors applied
into a stand-alone table so that they can be recalled next time the
session is opened.
Now, im fairly new to VBA but the code below is nearly there - A user
can move slider bars (in code below, only one weighting is there for
testing purposes) which populates the variable EcS1_Wf
This is then written to the stand-alone table (WeightFactors).
However, it creates a new record everytime - I only need there to be
one record in the table (i.e. the Last sessions weightings)
How would you tweak the code to apply this?
Do you delete the row out at the beginning? Or change it so that
instead of inserting a new row, it updates a row?
Either way, bit stuck on how to change code. Any tips would be
nice...
Dim pWorkspaceFactory As IWorkspaceFactory
Dim pFeatWorkspace As IFeatureWorkspace
Set pWorkspaceFactory = New AccessWorkspaceFactory
Set pFeatWorkspace = pWorkspaceFactory.OpenFromFile(strDBpath, 0)
Set pWtFacTable = pFeatWorkspace.OpenTable("WeightFactors")
'Create a query filter to select row
Dim pQf As IQueryFilter
Set pQf = New QueryFilter
Dim pFcursor1 As ICursor
Set pFcursor1 = pWtFacTable.Search(Nothing, False)
'Get the rows that match the query filter
Dim pRow As IRow
Set pRow = pFcursor1.NextRow
If pRow Is Nothing Then
MsgBox "Please check format of weighting tables - process exiting !"
Exit Sub
Else
' Writing selected weighting factors to table
Dim pWgtInsCursor As ICursor
Set pWgtInsCursor = pWtFacTable.Insert(False)
Dim pWgtRowBuff As IRowBuffer
'Find fields
EcS1Wf_db = pWtFacTable.FindField("EC1_WSF")
'Write Fields to table
Set pWgtRowBuff = pWtFacTable.CreateRowBuffer
With pWgtRowBuff
.Value(EcS1Wf_db) = Me!EcS1_Wf.Value
End With
pWgtInsCursor.InsertRow pWgtRowBuff
End If
MsgBox "Finished Calculations", vbInformation
Set pMxDoc = ThisDocument
pMxDoc.ActiveView.Refresh
frmWtgs.Hide
- ArcMap mouse events through ArcObjects Java binding?
- Geographic Information Systems (GIS)
- 2005-05-25
- how to draw points in arcmap using arcobjects customization
- Geographic Information Systems (GIS)
- 2005-04-07
- Need Step-by-Step Help: How to Draw circle in ArcMap using ArcObjects..
- Geographic Information Systems (GIS)
- 2005-03-15
- GIS & VB
- Geographic Information Systems (GIS)
- 2007-03-06
