|
-
Jul 24th, 2003, 09:51 AM
#1
Thread Starter
Junior Member
Problem deleting last record(item)
Error i happening while I run my application. I am having trouble with my application. I have a Flex Grid running on my application. I have a Copy - Delete and New item buttons on my application. I can successfully delete the items (recordsets) on the grid however when I am deleting the last item left on the grid, I get a Run-time error which says "Can not remove last non-fixed row" Error 30015. Fairly news to VB please help me
Thanks in advance //let me know if u need any further info
CODE:
Private Sub Command2_Click()
FGActions.RemoveItem (FGActions.Row) ->>> ERROR REPORTED
End Sub
********************
CODE FOR FGAction
**********************
Private Sub FGActions_DblClick()
With FGActions
GCol = .Col
GRow = .Row
If .Row <> 0 And .Col < 2 Then
CellText.Top = .CellTop + .Top
CellText.Left = .CellLeft + .Left
CellText.Height = .CellHeight
CellText.Width = .CellWidth
CellText.Text = .Text
CellText.Visible = True
CellText.SetFocus
End If
If .Row > 0 And .Col = 3 Then
If .Text = "Running" Then
.Text = "Shut down"
Else
.Text = "Running"
End If
End If
If .Row > 0 And .Col = 2 Then
Combo2.Visible = True
Combo2.Top = .CellTop + .Top
Combo2.Left = .CellLeft + .Left
'Combo2.Height = .CellHeight
Combo2.Width = .CellWidth
End If
End With
End Sub
**************************
Private Sub FileNewAnalysis_Click()
Dim MyDB As Database, thesql As String, theset As Recordset
Dim MyDB2 As Database, thesql2 As String, theset2 As Recordset
CD.DialogTitle = "Enter the name of the new session..."
CD.Filter = "MS Access Database Files (*.mdb)|*.mdb|All Files (*.*)|*.*"
CD.filename = ""
CD.ShowOpen
temp2 = CD.filename
If temp2 = "" Then
StatusBar1.Panels(2).Text = "Filename not valid. Operation aborted."
Call FileClose_Click
Exit Sub
Else
GlobalVar.MainDBName = temp2
End If
thestart:
CD.DialogTitle = "Enter the file name and location to import..."
CD.Filter = "MS Access Database Files (*.mdb)|*.mdb|All Files (*.*)|*.*"
CD.filename = ""
CD.ShowOpen
temp = CD.filename
If temp = "" Then
StatusBar1.Panels(2).Text = "Filename not valid. Operation aborted."
Exit Sub
End If
Set MyDB = OpenDatabase(temp)
thesql = "SELECT * FROM FMEAData"
On Error Resume Next
Set theset = MyDB.OpenRecordset(thesql)
If Err.Number <> 0 Then
MsgBox ("The file is not of recognized format. Please retry.")
GoTo thestart
End If
Err.Clear
theset.Close
CreateMainDB temp2
Set MyDB = OpenDatabase(temp)
Set MyDB2 = OpenDatabase(temp2)
thesql = "SELECT * FROM ATeam"
Set theset = MyDB.OpenRecordset(thesql)
Set theset2 = MyDB2.OpenRecordset(thesql)
Do While theset.EOF = False
theset2.AddNew
For k = 0 To theset.Fields.Count - 1
theset2.Fields(k) = theset.Fields(k)
Next k
theset2.Update
theset.MoveNext
Loop
thesql = "SELECT * FROM GenInfo"
Set theset = MyDB.OpenRecordset(thesql)
Set theset2 = MyDB2.OpenRecordset(thesql)
Do While theset.EOF = False
theset2.AddNew
For k = 0 To theset.Fields.Count - 1
theset2.Fields(k) = theset.Fields(k)
Next k
theset2.Update
theset.MoveNext
Loop
thesql = "SELECT * FROM FMEAData"
thesql2 = "SELECT * FROM MPSData"
Set theset = MyDB.OpenRecordset(thesql)
Set theset2 = MyDB2.OpenRecordset(thesql2)
Do While theset.EOF = False
theset2.AddNew
For k = 0 To theset.Fields.Count - 1
theset2.Fields(k) = theset.Fields(k)
Next k
theset2.Update
theset.MoveNext
Loop
thesql = "SELECT * FROM FMEAMaintActions"
thesql2 = "SELECT * FROM MPSMaintActions"
Set theset = MyDB.OpenRecordset(thesql)
Set theset2 = MyDB2.OpenRecordset(thesql2)
Do While theset.EOF = False
theset2.AddNew
For k = 0 To theset.Fields.Count - 1
theset2.Fields(k) = theset.Fields(k)
Next k
theset2.Update
theset.MoveNext
Loop
LoadExistingFMEA temp2
LoadAssemMainTree temp2, Combo1.Text
LoadATeamGenInfo temp2
MPSMain.Caption = "Setting (Database in use: " & GlobalVar.MainDBName & ")"
End Sub
-
Jul 24th, 2003, 10:13 AM
#2
This is a known problem with the FlexGrid. The solution is to check the number of rows beforehand and use a different method to delete the last row.
VB Code:
Private Sub Command2_Click()
Select Case FGActions.Rows
Case > 2
FGActions.RemoveItem (FGActions.Row)
Case 2
FGActions.Rows = 1
Case Else
'trying to delete the fixed header row, just ignore it
End Select
End Sub
In the future can you just post the code that is relevant to the problem. Also, surround the code with the "[ vbcode] [ /vbcode]" tags.
Thanks.
-
Jul 24th, 2003, 10:25 AM
#3
Thread Starter
Junior Member
Thank you
It worked...perfect.... !!!!!!
Thank you much,,,....
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
|