ProModel Data Object Guide
ProModel Data Object Guide
ActiveX
Chapter 4:
The ProModel Data Object
(ProModel.CProModelData)
The ProModelData object is found in the ProModel Type Library. If you do not see this library in your references
list, you will need to run PM.exe with the “/regserver” command line option.
This object provides access to your model data, such as Locations, Subroutines, etc. The ProModelData object must
be initialized by the Populate method. With the methods listed below, you can read your model information, change
it, even delete it. This is a powerful tool and must be used with caution. It is a good idea to always make a backup
copy of your original model before using the ProModelData object to make changes.
•AddBackgroundBitmap
•AppendEntitySpot
•AppendGraphicIcon
•AppendGraphicIconSize
•AppendRecord
•AppendRoutingPoint
•DeleteRecord
•GetIntFieldValue
•GetRealFieldValue
•GetRecordCount
•GetSelectedsFromType
•GetStringFieldValue
•InsertRecord
•Populate
•SelectMainRecordByIndex
•SelectMainRecordByName
•SetIntFieldValue
•SetRealFieldValue
•SetStringFieldValue
58 Chapter 4:
AddBackgroundBitmap
AddBackgroundBitmap
Syntax: AddBackgroundBitmap RecordType, Filename, Xpos, Ypos, Percent
Description: Adds the bitmap in the specified file to the background of the current model. When adding
more than one bitmap, they are placed one on top of the other, so be sure to add the one(s) in back first. It
is best to use the ProModel object’s Zoom method to set the zoom to 100% before adding any graphics.
You may also want to use the RedrawLayout method after adding new graphics (they may not show until
you do).
Parameters:
RecordType (Long) 49 - Background Graphics Table, is the only value allowed.
Filename (String) Path & filename of Bitmap, Windows Metafile or Enhanced Metafile.
Xpos (Double) How far (in pixels) from the left margin of the layout to place the left edge of
the bitmap.
Ypos (Double) How far (in pixels) from the top margin of the layout to place the top edge of
the bitmap
Percent (Double) Factor by which bitmap will be compressed or expanded from its original
size. (1.0 = 100%)
Example: The following example creates a new model, ensures that the zoom is set to 100%, then adds a
background bitmap.
Sub AddGfx()
AppendEntitySpot
Syntax: AppendRecord RecordIndex, XPosition, YPosition
Description: Appends an Entity Spot graphic to an existing Location record.
Parameters:
RecordIndex (Long) The Record Index (Row Number) of the Location you wish to add an Entity
Spot to.
XPosition (Double) Number of pixels over from the left margin of the layout to place the entity
spot.
YPosition (Double) Number of pixels down from the top margin of the layout to place the entity
spot.
Example: This example loads the mfg_cost model, adds a record to the Locations table, names the new
location & gives it an Entity Spot graphic icon.
Sub AddGfx()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim recnum As Long
Dim fieldnum As Long
Dim subtable As Long
pmDataObject.AppendRecord 1
pmDataObject.GetRecordCount 1, recnum
pmDataObject.SetStringFieldValue 1, 2, "My_New_Loc"
pmDataObject.AppendEntitySpot recnum, 45, 90
Note: An entity spot can also be added by appending a location graphic record and changing the type field
to Enitity Spot (type 7). See “Working with Graphics” on page 6.
60 Chapter 4:
AppendGraphicIcon
AppendGraphicIcon
Syntax: AppendGraphicIcon RecordType, RecordIndex, GraphicNumber, XPos, YPos
Description: Appends a graphic to an existing Location, Entity or Resource record, without changing its
size.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to work with.
RecordIndex (Long) The Record Index (Row Number) of the Location, Entity or Resource you wish
to add a graphic icon to.
GraphicNumber (Long) Index number of a graphic icon in the Graphics Library specified in the Gen-
eral Information dialog of the loaded model. Keep in mind that the numbers are not
necessarily sequential, there may be gaps.
XPos (Double) Number of pixels from the left margin to place the graphic icon.
YPos (Double) Number of pixels from the top margin to place the graphic icon.
Example: This example loads a model, adds a record to the Locations table, then appends a graphic icon
to the new record.
Sub AddGfx()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim recnum As Long
AppendGraphicIconSize
Syntax: AppendGraphicIconPercent RecordType, RecordIndex, GraphicNumber, Xpos, Ypos, Xsize,
Ysize
Description: Appends a graphic to an existing Location, Entity or Resource record. This method lets you
specify the size of the graphic as a percentage of its original size.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to work with.
RecordIndex (Long) The Record Index (Row Number) of the Location, Entity or Resource you wish
to add a graphic icon to.
GraphicNumber (Long) Index number of a graphic icon in the Graphics Library specified in the Gen-
eral Information dialog of the loaded model. Keep in mind that the numbers are not
necessarily sequential, there may be gaps.
Xpos (Double) Number of pixels from the left margin to place the graphic icon.
Ypos (Double) Number of pixels from the top margin to place the graphic icon.
Xsize (Double) Width in pixels.
Ysize (Double) Height in pixels.
Example: This example loads a model, adds a record to the Locations table, then appends a graphic icon
to the new record and makes it 50 x 50 pixels.
Sub AddGfx()
Dim pmObject As ProModel.CProModel
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim recnum As Long
AppendRecord
Syntax: AppendRecord RecordType
Description: Adds a new record to the end of the specified table. When using AppendRecord, you may
use the Set…FieldValue methods without first calling the SelectRecordBy… method. However, if you are
using a method that requires the Record Index number as a parameter, you will need to get that number
with the GetRecordCount method (or any other method that returns that information).
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to add a record to.
Example: This example loads the mfg_cost model, adds a new record to the Locations table, and then
changes the location name to My_New_Loc.
Sub AppRec()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
AppendRoutingPoint
Syntax: AppendRoutingPoint XPosition, Yposition
Description: Adds a new Routing Point and connects the previous end point to the new point. You must
first select the Processing and Routing records you wish to append the new Routing Point to.
Parameters:
Xposition (Double) Number of pixels from the left margin of the layout to place the Routing
Point.
Yposition (Double) Number of pixels from the top margin of the layout to place the Routing
Point.
Example: The following example loads the mfg_cost model, selects the first processing record, then
selects the second routing record for that process and adds a new point.
Sub AddAPoint()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
pmDataObject.SelectMainRecordByIndex 19, 1
pmDataObject.SelectMainRecordByIndex 20, 2
pmDataObject.AppendRoutingPoint 125, 90
DeleteRecord
Syntax: DeleteRecord RecordType
Description: Deletes the currently selected record from the specified table. Be very careful when using
this method, because it will delete records without any data integrity checking. This means that even if the
record is referenced by a record in another table, it will be deleted and make the other record invalid.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to delete a record
from.
Example: The following example deletes all records from the Locations table in the mfg_cost model. Be
careful with this one, or you could disable the mfg_cost demo model if you then save it.
Sub EmptyLocs()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim rec_count As Long
pmDataObject.GetRecordCount 1, rec_count
For x = 1 To rec_count
pmDataObject.SelectMainRecordByIndex 1, 1
pmDataObject.DeleteRecord 1
Next x
GetIntFieldValue
Syntax: GetIntFieldValue RecordType, FieldNumber, FieldValue
Description: Returns the value of the specified integer field from the selected record.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to work with.
FieldNumber (Long) The field (column) number in the specified table from which you want to return
a value.
FieldValue (Long) Data value contained in the specified field for the selected record. This must
be a variable.
Example: The following example gets the value of the Default Time units from the mfg_cost model, then
displays a message with that information.
Sub GetTimeUnits()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim TimeUnit As Long
pmDataObject.SelectMainRecordByIndex 18, 1
pmDataObject.GetIntFieldValue 18, 2, TimeUnit
GetRealFieldValue
Syntax: GetIntFieldValue RecordType, FieldNumber, FieldValue
Description: Returns the value of the specified real number field from the selected record.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to work with.
FieldNumber (Long) The field (column) number in specified table from which you want to return a
value.
FieldValue (Long) Data value contained in the specified field for the selected record. This must
be a variable.
Example: The following example selects the second routing record (not necessarily the second routing
block) of the first processing record, gets the Probability value and displays it in a message box.
Sub SetRoutingProbability()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim ProbValue As Double
pmDataObject.SelectMainRecordByIndex 19, 1
pmDataObject.SelectMainRecordByIndex 20, 2
pmDataObject.GetRealFieldValue 20, 13, ProbValue
pmObject.MsgBox “Probability = “ & ProbValue
GetRecordCount
Syntax: GetRecordCount RecordType, Count
Description: Returns the current number of records in the specified table. This is very useful in looping
through each record in a table of unknown size.
Parameters:
RecordType (Long) The Record Type (Table Number) for which you want the record count.
Count (Long) Returns the number of records in the specified table.
Example: The following example loads the mfg_cost model, gets the record count from the Locations
table, then displays a message telling the user how many locations there are.
Sub HowManyLocs()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim rec_count As Long
pmDataObject.GetRecordCount 1, rec_count
If rec_count = 1 Then
pmObject.MsgBox "There is 1 location in this model"
Else
pmObject.MsgBox "There are " & rec_count & " locations in this model"
End If
GetSelectedsFromType
Syntax: GetSelectedsFromType RecordType, MainIndex, Field, SubIndex
Description: Returns record index values for the currently selected main and sub records.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you want to work with.
MainIndex (Long) Returns Record Index (row number) of the currently selected record.
Field (Long) Although this parameter is no longer used, it is still required. It returns -1.
SubIndex (Long) Although this parameter is no longer used, it is still required. It returns -1.
Example: The following example loads the mfg_cost model, finds the “Inspect” location and displays a
message telling the user what the index number is for that record.
Sub WhatsMyIndex()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim recnum As Long
Dim fieldnum As Long
Dim subrec As Long
pmDataObject.SelectMainRecordByName 1, "Inspect"
pmDataObject.GetSelectedsFromType 1, recnum, fieldnum, subrec
pmObject.MsgBox "Location <Inspect> is Record Index #" & recnum
GetStringFieldValue
Syntax: GetStringFieldValue RecordType, FieldNumber, FieldValue
Description: Returns the value of the specified string field from the selected record.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you want to work with.
FieldNumber (Long) The field (column) number in specified table from which you want to return a
value.
FieldValue (Long) Data value contained in the specified field for the selected record. This must
be a variable.
Example: The following example steps through the Macros table, gets the name and value of each
macro, then displays a message with that information.
Sub GetMacros()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim i As Integer
Dim RecCount As Long
Dim MacName As String
Dim MacText As String
For i = 1 To RecCount
pmDataObject.SelectMainRecordByIndex 11, i
pmDataObject.GetStringFieldValue 11, 1, MacName
pmDataObject.GetStringFieldValue 11, 2, MacText
pmObject.MsgBox (MacName & ": " & MacText)
Next i
InsertRecord
Syntax: InsertRecord RecordType
Description: Inserts a new record before the selected record in the table. The newly inserted record will
already be selected, so there is no need to use the SelectMainRecordBy… methods before populating the
data.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to insert the record
into.
Example: The following example loads the mfg_cost model, finds the “Inspect” location and inserts a new
record before it, then selects the new record & gives it a name.
Sub AddALoc()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
pmDataObject.SelectMainRecordByName 1, "Inspect"
pmDataObject.InsertRecord 1
pmDataObject.SetStringFieldValue 1, 2, "My_New_Loc"
pmObject.MsgBox "Done"
Populate
Syntax: Populate
Description: Populates the ProModelData object with the current, loaded model data. Call this method
before using the data object. You must call the Populate method to initialize the ProModelData object with
the model’s current information. Use Populate each time you open or close a model, or if you add or
remove records.
Example: This example loads the mfg_cost model and populates the ProModelData object.
Sub AddALoc()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
SelectMainRecordByIndex
Syntax: SelectMainRecordByIndex RecordType, RecordIndex
Description: Selects a record by its Record Index (row number). This method is very useful in looping
through all the records in a table.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to work with.
RecordIndex (Long) The Record Index (Row Number) of the record you wish to select.
Example: The following example steps through the Macros table, selecting each record by Index Number,
then gets the name and value of each macro, then displays a message with that information.
Sub GetMacros()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim i As Integer
Dim RecCount As Long
Dim MacName As String
Dim MacText As String
For i = 1 To RecCount
pmDataObject.SelectMainRecordByIndex 11, i
pmDataObject.GetStringFieldValue 11, 1, MacName
pmDataObject.GetStringFieldValue 11, 2, MacText
pmObject.MsgBox (MacName & ": " & MacText)
Next i
SelectMainRecordByName
Syntax: SelectMainRecordByName RecordType, RecordName
Description: Selects a record by its Name or ID value. This method can only be used with record types
that have a name or ID field. If the table does not have a Name or ID field, you must use the SelectMain-
RecordByIndex method.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to work with.
RecordName Long) The Name or ID field value for the record (row) you wish to select.
Example: The following example loads the mfg_cost model, selects the location record by the name
“Inspect”, inserts a new record before it, and gives it a name.
Sub AddALoc()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
pmDataObject.SelectMainRecordByName 1, "Inspect"
pmDataObject.InsertRecord 1
pmDataObject.SetStringFieldValue 1, 2, "My_New_Loc"
pmObject.MsgBox "Done"
SetIntFieldValue
Syntax: SetIntFieldValue RecordType, FieldIndex, FieldValue
Description: Changes the value for the specified integer field of the selected record.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to work with.
FieldIndex (Long) The Field Index (Column Number) of the field you wish to make changes to.
FieldValue (Long) The integer (long) value you want to place in the specified field.
Example: The following example loads the mfg_cost model, then sets its default time unit to Hours (it was
Minutes).
Sub Time2Hours()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim TimeUnit As Long
TimeUnit = 3 '(Hours)
pmDataObject.SelectMainRecordByIndex 18, 1
pmDataObject.SetIntFieldValue 18, 2, TimeUnit
SetRealFieldValue
Syntax: SetRealFieldValue RecordType, FieldIndex, FieldValue
Description: Changes the value for the specified real field of the selected record. When setting values for
real fields, it is best to place the number into a variable of the correct type, then use the variable in the
method call. This will avoid incorrect numeric conversions.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to work with.
FieldIndex (Long) The Field Index (Column Number) of the field for which you want to change
the value.
FieldValue (Double) The real number value you wish to place in the specified field for the
selected record.
Example: The following example loads the Orders model, selects the third processing record, then
changes the probabilities for the routing records to 70/30. Be cautious with using this method to set prob-
abilities or percentages that must total 100 (make sure the records still have the correct total after
changes).
Sub GetRoutingProbability()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
Dim ProbVal1 As Double
Dim ProbVal2 As Double
ProbVal1 = 0.7
ProbVal2 = 0.3
pmDataObject.SelectMainRecordByIndex 19, 3
pmDataObject.SelectMainRecordByIndex 20, 1
pmDataObject.SetRealFieldValue 20, 13, ProbVal1
pmDataObject.SelectMainRecordByIndex 20, 2
pmDataObject.SetRealFieldValue 20, 13, ProbVal2
pmObject.MsgBox ("Done")
SetStringFieldValue
Syntax: SetStringFieldValue RecordType, FieldIndex, FieldValue
Description: Changes the value for the specified string field of the selected record.
Parameters:
RecordType (Long) The Record Type (Table Number) of the table you wish to work with.
FieldIndex (Long) The Field Index (Column Number) of the field in which you want to place the
new value.
FieldValue (String) The value you wish to place in the specified field for the selected record.
Example: The following example loads the mfg_cost model, finds the “Inspect” location and inserts a new
record before it, then selects the new record & gives it a name.
Sub AddALoc()
Dim pmObject As ProModel.CProModel
Dim pmDataObject As ProModel.CProModelData
pmDataObject.SelectMainRecordByName 1, “Inspect”
pmDataObject.InsertRecord 1
pmDataObject.SetStringFieldValue 1, 2, “My_New_Loc”
Chapter 5:
The RDBDataServer Object
To use the RDBDataServer object, you will first need to register the RDBDataServer. This is done by running the
RDBSRV.EXE found in your ProModel folder. If you do not have this file in your ProModel folder, contact Pro-
Model Technical Support. You will not find a library for this object listed in the references in your VB Editor.
As you work with the RDBDataServer, keep in mind that you are working with a database, not a text file or spread-
sheet. This means that there is some information that you cannot get directly from the .rdb file. For example, when
you have multiple replications, periods, or scenarios, you can’t get the averages, standard deviations or totals using
only the RDBDataServer methods. You must get the same data elements from each replication, period or scenario,
then perform the calculations in your spreadsheet or other program.
When talking about tables, each section of the standard output statistics report corresponds to a table in the .rdb file.
There are some tables that may or may not be available, depending upon whether that type of data is collected for the
specific model (like Logs). However, the table numbers are pre-defined, so each number will always reference the
same table, whether or not it is in use.
If you want to get the names of the records (i.e. – Location or Resource Names), you will need to get the data for field
number 0 (zero). The zero column in each table has the Record ID from the model.
•CloseFile
•FieldName
•GetPositionInfo
•GetValue
•OpenFile
•PeriodName
•PositionIsValid
•RecordName
•ReplicationNumber
•ScenarioName
•SelectData
•TableName
78 Chapter 5:
CloseFile
CloseFile
Syntax: CloseFile
Description: Closes the previously opened RDB file.
Parameters: None
Returns: Nothing
Example: This example opens the mfg_cost.rdb, selects data, displays it, then closes the file.
Sub Get_Data()
Dim RDBObj As Object
Dim x
RDBObj.SelectData 1, 1, 1, 1, 1, 1
x = RDBObj.GetPositionInfo
MsgBox (x)
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
ProModel 79
ActiveX
FieldName
Syntax: FieldName
Description: Returns the name of the current field.
Parameters: None
Returns: The name of the specified field (column), or “invalid” if the SelectData specifications are not
valid.
Example: This example opens the mfg_cost.rdb, displays some of the data, then closes the file.
Sub Get_Data()
Dim RDBObj As Object
Dim MyField As String
RDBObj.SelectData 1, 1, 1, 1, 1, 1
If RDBObj.PositionIsValid = True Then
MyField = RDBObj.FieldName
MsgBox ("Field (Column): " & MyField)
Else
MsgBox ("Data Selection Invalid")
End If
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
80 Chapter 5:
GetPositionInfo
GetPositionInfo
Syntax: GetPositionInfo
Description: Returns the scenario, period, replication, table, field, record and data value of the current
selection. This can be useful in loops.
Returns: Details of current data selection, as follows:
Scenario: Scenario Name
Replication: Replication Number
Period: Period Name
Table: Table Name
Field: Field Name
Record: Record Name
Value: Data Value
Parameters: None
Example: This example opens the mfg_cost.rdb, selects data, then displays the details of the selection.
Sub Get_Data()
Dim RDBObj As Object
Dim x
RDBObj.SelectData 1, 1, 1, 1, 1, 1
x = RDBObj.GetPositionInfo
MsgBox (x)
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
ProModel 81
ActiveX
GetValue
Syntax: GetValue
Description: Returns the data value for the current data selection.
Parameters: None
Returns: The data value of the current position (or zero if the current selection is not valid).
Example: This example opens the mfg_cost.rdb, gets and displays some of the data, then closes the file.
Sub Get_Data()
Dim RDBObj As Object
Dim MyDataVal As String
RDBObj.SelectData 1, 1, 1, 1, 1, 1
If RDBObj.PositionIsValid = True Then
MyDataVal = RDBObj.GetValue
MsgBox ("Data Value = " & MyDataVal)
Else
MsgBox ("Data Selection Invalid")
End If
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
82 Chapter 5:
OpenFile
OpenFile
Syntax: OpenFile FileName
Description: Call this function first to open and load the proper .RDB file.
Parameters:
FileName (String) Path and filename of any valid .rdb file.
Returns: Nothing
Example: This example opens the mfg_cost.rdb, gets and displays some of the data, then closes the file.
Sub Get_Data()
Dim RDBObj As Object
Dim x
RDBObj.SelectData 1, 1, 1, 1, 1, 1
x = RDBObj.GetPositionInfo
MsgBox (x)
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
ProModel 83
ActiveX
PeriodName
Syntax: PeriodName
Description: Returns the name of the Period in the current data selection.
Parameters: None
Returns: The current period name, or “invalid” if the current selection is not valid.
Example: This example opens the mfg_cost.rdb, gets and displays some of the data, then closes the file.
Sub Get_Data()
Dim RDBObj As Object
Dim MyPeriod As String
RDBObj.SelectData 1, 1, 1, 1, 1, 1
If RDBObj.PositionIsValid = True Then
MyPeriod = RDBObj.PeriodName
MsgBox ("Selected Period = " & MyPeriod)
Else
MsgBox ("Data Selection Invalid")
End If
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
84 Chapter 5:
PositionIsValid
PositionIsValid
Syntax: PositionIsValid
Description: Check the data for the most recent data selection & return “True” if it is valid, “False” if it is
not. This method is a little tricky, because it really doesn’t do much unless it is used in an “If…Then” or
“Select Case” statement (the ‘x = RDBObj.PositionIsValid’ format is not allowed)
Parameters: None
Returns: TRUE if the last SelectData function points to valid data. FALSE if it does not.
Example: This example opens the mfg_cost.rdb, selects data, checks to see if selection is valid, displays
the data or an error message, then closes the file.
Sub Get_Data()
Dim RDBObj As Object
Dim MyPeriod As String
RDBObj.SelectData 1, 1, 1, 1, 1, 1
If RDBObj.PositionIsValid = True Then
MyPeriod = RDBObj.PeriodName
MsgBox ("Selected Period = " & MyPeriod)
Else
MsgBox ("Data Selection Invalid")
End If
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
ProModel 85
ActiveX
RecordName
Syntax: RecordName
Description: Returns the name of the Record in the current data selection.
Parameters: None
Returns: The current record name, or “invalid” if the current selection is not valid.
Example: This example opens the mfg_cost.rdb, gets and displays some of the data, then closes the file.
Sub Get_Data()
Dim RDBObj As Object
Dim MyRecord As String
RDBObj.SelectData 1, 1, 1, 1, 1, 1
If RDBObj.PositionIsValid = True Then
MyRecord = RDBObj.RecordName
MsgBox ("Selected Record = " & MyRecord)
Else
MsgBox ("Data Selection Invalid")
End If
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
86 Chapter 5:
ReplicationNumber
ReplicationNumber
Syntax: ReplicationNumber
Description: Returns the number of the Replication in the current data selection.
Parameters: None
Returns: The current replication number, or “invalid” if the current selection is not valid.
Example: This example opens the mfg_cost.rdb, gets and displays some of the data, then closes the file.
Sub Get_Data()
Dim RDBObj As Object
Dim RepNum As String
RDBObj.SelectData 1, 1, 1, 1, 1, 1
If RDBObj.PositionIsValid = True Then
RepNum = RDBObj.ReplicationNumber
MsgBox ("Selected Replication = " & RepNum)
Else
MsgBox ("Data Selection Invalid")
End If
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
ProModel 87
ActiveX
ScenarioName
Syntax: ScenarioName
Description: Returns the name of the Scenario in the current data selection.
Parameters: None
Returns: The current scenario name, or “invalid” if the current selection is not valid.
Example: This example opens the mfg_cost.rdb, gets and displays some of the data, then closes the file.
Sub Get_Data()
Dim RDBObj As Object
Dim MyScenario As String
RDBObj.SelectData 1, 1, 1, 1, 1, 1
If RDBObj.PositionIsValid = True Then
MyScenario = RDBObj.ScenarioName
MsgBox ("Selected Scenario = " & MyScenario)
Else
MsgBox ("Data Selection Invalid")
End If
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub
88 Chapter 5:
SelectData
SelectData
Syntax SelectData Scenario, Replication, Period, Table, Field, Record
Description: Retrieves the specified data element from the .rdb file. All of the parameters must be speci-
fied, even if there is only one scenario, replication or period.
Parameters:
Scenario (Long) Scenario number containing the data you wish to select.
Replication (Long) Replication number containing the data you wish to select.
Period (Long) Period number containing the data you wish to select.
Table (Long) Table (report section) number containing the data you wish to select.
Field (Long) Field (column) number containing the data you wish to select.
Record (Long) Record (row) number containing the data you wish to select.
Returns: TRUE if there is valid data corresponding to the parameters.
Example: This example opens the mfg_cost.rdb, gets and displays the Scheduled Hours for the first listed
location in the Locations section of the statistic report (first scenario, replication & period), then closes the
file.
Sub Get_Data()
Dim RDBObj As Object
Dim MyScenario As String
RDBObj.SelectData 1, 1, 1, 1, 1, 1
If RDBObj.PositionIsValid = True Then
MyScenario = RDBObj.ScenarioName
MsgBox ("Selected Scenario = " & MyScenario)
Else
MsgBox ("Data Selection Invalid")
End If
RDBObj.CloseFile
Set RDBObj = Nothing
End Sub