|
-
August 8th, 2003, 05:47 AM
#1
Problems while Loading a file.
I am having a weird problem in my application. the problem occurs when I am opening an existing database file on my application. If I press Cancel on the Open Exisiting file dialog box, the application defaultly opens the last database it opened instead of just doing nothing. If you do selected ok to open a database, the application goes through and opens it..which is fine..How do I fix this problem. Here is the relevant code for File Load
Private Sub FileLoad_Click()
CD.Flags = cdlOFNFileMustExist
On Error GoTo fokop
CellText.Visible = False
CD.DialogTitle = "Load existing analysis..."
CD.Filter = "MS Access Database Files (*.mdb)|*.mdb|All Files (*.*)|*.*"
CD.ShowOpen
GlobalDatabaseName = CD.FileName
If GlobalDatabaseName = "" Then
Exit Sub
End If
Dim MyDB As Database, thesql As String, theset As Recordset
Set MyDB = OpenDatabase(GlobalDatabaseName)
thesql = "SELECT * FROM HeaderData"
Set theset = MyDB.OpenRecordset(thesql)
If theset.EOF = False Then
theset.MoveFirst
Text21.Text = Replace(FixNull(theset.Fields(0).Value), "@@@", "")
Text22.Text = Replace(FixNull(theset.Fields(1).Value), "@@@", "")
Text23.Text = Replace(FixNull(theset.Fields(2).Value), "@@@", "")
DTPicker1.Value = FixNull(theset.Fields(3).Value)
DTPicker1.Value = FixNull(theset.Fields(4).Value)
Text24.Text = Replace(FixNull(theset.Fields(5).Value), "@@@", "")
Text25.Text = Replace(FixNull(theset.Fields(6).Value), "@@@", "")
Text26.Text = Replace(FixNull(theset.Fields(7).Value), "@@@", "")
Text1.Text = Replace(FixNull(theset.Fields(8).Value), "@@@", "")
End If
theset.Close
thesql = "SELECT AssemblyName FROM SparesData GROUP BY [AssemblyName]"
Set theset = MyDB.OpenRecordset(thesql)
If theset.EOF = False Then
Combo1.Clear
theset.MoveFirst
Do While theset.EOF = False
Combo1.AddItem theset.Fields(0).Value
theset.MoveNext
Loop
Combo1.Text = Combo1.List(0)
End If
theset.Close
thesql = "SELECT * FROM AnalysisTeam"
Set theset = MyDB.OpenRecordset(thesql)
If theset.EOF = False Then
theset.MoveFirst
k = 0
Do While theset.EOF = False
k = k + 1
FGATeam.TextMatrix(k, 0) = Replace(theset.Fields(0).Value, "@@@", "")
FGATeam.TextMatrix(k, 1) = Replace(theset.Fields(1).Value, "@@@", "")
FGATeam.TextMatrix(k, 2) = Replace(theset.Fields(2).Value, "@@@", "")
theset.MoveNext
Loop
End If
theset.Close
Frame2.Visible = True
SparesMain.Caption = "Spares Definition (" & GlobalDatabaseName & ")"
Call LoadTreeFromAccess
Call FixTreeText
StatusBar1.Panels(2).Text = "File loaded successfully."
Exit Sub
fokop:
StatusBar1.Panels(2).Text = "Unable to perform operation."
Call FileExport_Click
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|