double click..

  • Thread starter Thread starter Pam
  • Start date Start date
P

Pam

When I double click on a event in a form I want it to
bring up another form and load the same data so it can be
edited.

I'm having a hard time doing this. The new form loads;but
my file can't be found. Can you can me some ideas on how
to do this.

Please help!!
 
Hi Pam,

You're not telling us much. :-(

What data? What file?

Can you show us what you're doing and tell us what does/doesn't happen?

Regards,
Fergus
 
Hello,

Pam said:
When I double click on a event in a form I want it to
bring up another form and load the same data so it can be
edited.

I'm having a hard time doing this. The new form loads;but
my file can't be found. Can you can me some ideas on how
to do this.

What file? Please post some code.
 
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
 
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
 
Hi Pam,

So what's actually going wrong. What's stopping you do the same thing on
the second form?

Is there something wrong in the code that you gave us? If so, any clues?
If not, what is it supposed to show us?

In other words - Please spell out the problem as if I'm an idiot. ;-)

Regards,
Fergus
 
The problem in the second is isn't putting the data in the
form. I get an error saying file not found. It's not
passing the ScenarioName to the dblclick subrountine.
 
Back
Top