Below is a small sample of the code that loads the first
form. Once I double click on the edit part I want it to
call another form (that I have already created) and load
the event data of the same scenario that was on this first
form.
Pam
Public Function LoadScenarioForEdit(ScenarioName As
String) As Boolean
Dim filenum As Integer, strData As String, dlim As
String * 1, i As Integer
LoadScenarioForEdit = True
Me.Tag = ScenarioName
Me.Caption = ScenarioName & " - Scenario Editor"
ScenarioInfoFile = ROOT_DIR & WORK_DIR & ScenarioName
& "." & ScenarioInfo_EXT
ScenarioEventFile = ROOT_DIR & WORK_DIR & ScenarioName
& "." & ScenarioEvent_EXT
'Load scenario information file
filenum = FreeFile
On Error Resume Next
Open ScenarioInfoFile For Input As #filenum
Line Input #filenum, strData
Close #filenum
If InStr(strData, vbTab) = 0 Then 'Tab delimiter
not found
If InStr(strData, ";") <> 0 Then
dlim = ";"
End If
If InStr(strData, ",") <> 0 Then
dlim = ","
End If
If dlim = " " Then 'Unable to determine data
delimiter
MsgBox "No valid data delimiter for file "
& filename, vbCritical
Else 'Convert delimiter to tab
Do
i = InStr(strData, dlim)
strData = Left(strData, i - 1) & vbTab &
Right(strData, Len(strData) - i)
Loop While InStr(strData, dlim) > 0
End If
End If
With dgdScenarioInfo
.AddItem strData
txtName.Text = .TextMatrix(0, 0)
txtVersion.Text = .TextMatrix(0, 1)
txtModDate.Text = .TextMatrix(0, 2)
txtHours.Text = .TextMatrix(0, 5)
txtRate.Text = .TextMatrix(0, 3)
lblRunTimeValue.Caption = .TextMatrix(0, 4)
lblSEvalue.Caption = .TextMatrix(0, 6)
lblEIvalue.Caption = .TextMatrix(0, 7)
lblREvalue.Caption = .TextMatrix(0, 8)
txtComment.Text = .TextMatrix(0, 9)
End With
End If
'Load scenario event file
dlim = " "
filenum = FreeFile
On Error Resume Next
Open ScenarioEventFile For Input As #filenum
If Err.Number <> 0 Then
strData = "Error opening file " &
ScenarioEventFile & " Error: " & Err.Number & " " &
Err.Description
WriteLog strData
MsgBox strData, vbCritical, "Edit scenario " &
ScenarioName
LoadScenarioForEdit = False
Exit Function
Else
Line Input #filenum, strData
If InStr(strData, vbTab) = 0 Then 'Tab delimiter
not found
If InStr(strData, ";") <> 0 Then dlim = ";"
If InStr(strData, ",") <> 0 Then dlim = ","
If dlim = " " Then 'Unable to determine data
delimiter
MsgBox "Unable to determine file delimiter
for file " & filename, vbCritical
Else 'Convert delimiter to tab
Do
i = InStr(strData, dlim)
strData = Left(strData, i - 1) & vbTab &
Right(strData, Len(strData) - i)
Loop While InStr(strData, dlim) > 0
End If