|
-
May 7th, 2002, 02:03 AM
#1
Thread Starter
Lively Member
Anybody heard of bookmarks (not in IE!!)?
Hi there,
I'm currently conversing a DOA application to an ADO application and here is one of the problems I encountered:
Previously the DBgrid was used to show the data. Since that is an DOA component I use the MSHFlexgrid at the moment.
There are a lot of procedures that use the Selbookmarks property of the DBgrid, and there is no such property for the MSHFlexgrid.
Can anyone tell me what this property is normally used for and if there is a similar property for the MSHFlexGrid?
If you need an example of the code let me know.
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 7th, 2002, 02:39 AM
#2
Bookmarks... used in bound recordsets to mark where the record was before the current record was changed. I think.
Personally I don't use them and if you are converting to ADO from DAO, then you should be able to mimic the same thing.
Firstly you need to find out exactly what the previous coder used it for. Paste chunk of code up if you can't seem to see what it means. Comeone should know the answer... whether they tell though 
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 7th, 2002, 02:52 AM
#3
Thread Starter
Lively Member
Okey here's a sample of the code, I hope someone can tell me how to adjust this to ADO and tell me what this piece of code does. B.T.W. this code is behind a delete record button.
VB Code:
Case BUTTON_VERWIJDEREN
If rs.RecordCount <> 0 Then
If grdDataGrid.SelBookmarks.Count <= 0 Then
gsFormParm = CMD_DELRCD & "|" & rs![OpdrachtId]
frmProductieOpdrachten.Show
Me.Enabled = False
Else
If GeneralDialog(DIATYPE_OPERATORQ, Me.Caption, _
"Weet u zeker dat u de geselecteerde productieorders wilt verwijderen?", "") = _
DIABUTTON_YES Then
ReDim arrCurrentSelection(grdDataGrid.SelBookmarks.Count - 1)
lNumberCurrentlySelected = grdDataGrid.SelBookmarks.Count
For iCnt = 0 To grdDataGrid.SelBookmarks.Count - 1
arrCurrentSelection(iCnt) = grdDataGrid.SelBookmarks(iCnt)
Next iCnt
' definieer hoogste en de laagste selectie plus de selectiegrootte
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
For iCnt = LBound(arrCurrentSelection) To UBound(arrCurrentSelection)
rs.Bookmark = arrCurrentSelection(iCnt)
If rs![OpdrachtId] < lBeginSelect Then 'lager dan de vorige waarde?
lBeginSelect = rs![OpdrachtId]
End If
If rs![OpdrachtId] > lEindeSelect Then ' hoger dan de vorige
lEindeSelect = rs![OpdrachtId]
End If
Next iCnt
'OMM 6-10-2000; Gewijzigd om alleen de Orders te selecteren
Set rsSelect = gdbsMainDB.OpenRecordset( _
"SELECT * FROM ProductieOrders WHERE IsOrder = True ")
rsSelect.FindFirst "OpdrachtId=" & lBeginSelect
Do While (Not rsSelect.EOF) _
And (lBeginSelect <= lEindeSelect)
'OMM 17-7-2000; Veranderd voor AS400 Koppeling
' alleen rsSelect.Delete bestond
If CheckProductieOrderHasCharge(rsSelect![bonnummer]) Then
rsSelect.Edit
rsSelect![IsVerwijderd] = True
rsSelect.Update
Else
rsSelect.Delete
End If
rsSelect.MoveNext
lBeginSelect = lBeginSelect + 1
Loop
iSelectRegel = 1 ' New Id for the first Order
' Eerst renumber
rsSelect.MoveFirst
Do While Not rsSelect.EOF
rsSelect.Edit
rsSelect![OpdrachtId] = iSelectRegel
rsSelect.Update
rsSelect.MoveNext
iSelectRegel = iSelectRegel + 1
Loop
rsSelect.Close
datPrimaryRs.Refresh
End If
End If
End If
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 7th, 2002, 04:01 AM
#4
Originally posted by WiseGuy
VB Code:
Case BUTTON_VERWIJDEREN
If rs.RecordCount <> 0 Then
[b]If there is [u]NO[/u] selected bookmarks (count less than or equal to 0) then set a form parameter.
Shows a new form and disabled the current one
[/b]
If grdDataGrid.SelBookmarks.Count <= 0 Then
gsFormParm = CMD_DELRCD & "|" & rs![OpdrachtId]
frmProductieOpdrachten.Show
Me.Enabled = False
Else
[b]
Note I don't understand holland speak so I may be missing something ;)
If you answer Yes, it creates an array of selected bookmarks.
(Assuming that the selected records in the dbGrid would be the bookmarks)
[/b]
If GeneralDialog(DIATYPE_OPERATORQ, Me.Caption, _
"Weet u zeker dat u de geselecteerde productieorders wilt verwijderen?", "") = _
DIABUTTON_YES Then
ReDim arrCurrentSelection(grdDataGrid.SelBookmarks.Count - 1)
lNumberCurrentlySelected = grdDataGrid.SelBookmarks.Count
For iCnt = 0 To grdDataGrid.SelBookmarks.Count - 1
arrCurrentSelection(iCnt) = grdDataGrid.SelBookmarks(iCnt)
Next iCnt
' definieer hoogste en de laagste selectie plus de selectiegrootte
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
[b]Looks like a loop through all array entries ...
Moves to the first bookmark (selected record)
Compares the start ID (currently max number of record +1)(see above) and either sets the beginning or End IDs
[/b]
For iCnt = LBound(arrCurrentSelection) To UBound(arrCurrentSelection)
rs.Bookmark = arrCurrentSelection(iCnt)
If rs![OpdrachtId] < lBeginSelect Then 'lager dan de vorige waarde?
lBeginSelect = rs![OpdrachtId]
End If
If rs![OpdrachtId] > lEindeSelect Then ' hoger dan de vorige
lEindeSelect = rs![OpdrachtId]
End If
Next iCnt
'OMM 6-10-2000; Gewijzigd om alleen de Orders te selecteren
Set rsSelect = gdbsMainDB.OpenRecordset( _
"SELECT * FROM ProductieOrders WHERE IsOrder = True ")
[b]Pull only records that the IsOrder has been set (has been ordered?)
For the beginning ID, find the first matching record.
While you still have records and the beginning ID is less than the end ID
Check if there is a product order charge.
Assume true = means there is one - then set the validated field of that record
False = Delete record - no charge made...
[/b]
rsSelect.FindFirst "OpdrachtId=" & lBeginSelect
Do While (Not rsSelect.EOF) _
And (lBeginSelect <= lEindeSelect)
'OMM 17-7-2000; Veranderd voor AS400 Koppeling
' alleen rsSelect.Delete bestond
If CheckProductieOrderHasCharge(rsSelect![bonnummer]) Then
rsSelect.Edit
rsSelect![IsVerwijderd] = True
rsSelect.Update
Else
rsSelect.Delete
End If
[b]move to the next record, adjust begining ID
[/b]
rsSelect.MoveNext
lBeginSelect = lBeginSelect + 1
Loop
[b]Possibly renumber records so they are consistant in incrementing numbers?[/b]
iSelectRegel = 1 ' New Id for the first Order
' Eerst renumber
rsSelect.MoveFirst
Do While Not rsSelect.EOF
rsSelect.Edit
rsSelect![OpdrachtId] = iSelectRegel
rsSelect.Update
rsSelect.MoveNext
iSelectRegel = iSelectRegel + 1
Loop
rsSelect.Close
datPrimaryRs.Refresh
End If
End If
End If
Does that help?
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 7th, 2002, 04:19 AM
#5
Thread Starter
Lively Member
yeah that does help, I know what it does now, but do you think that this is possible with ADO? 'couse there is no bookmark property for the MSHFlexgrid.
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 7th, 2002, 04:24 AM
#6
Yup.
Assuming you coded the filling of the flex (or if not for that matter) have a look at, um lets see if I can remember it, .RowSel or .Selected
Otherwise look at the help for flexgrids, if you set the multi select there should be a selected collection or you loop through top to bottom looking for those rows which have been selected.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 7th, 2002, 04:57 AM
#7
Thread Starter
Lively Member
I've tried what you've told me and this is how it looks now: I get the error 3001 which says: "The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another."
VB Code:
Case BUTTON_VERWIJDEREN
If rs.RecordCount <> 0 Then
If grdDataGrid.RowSel <= 0 Then
gsFormParm = CMD_DELRCD & "|" & rs![OpdrachtId]
frmProductieOpdrachten.Show
Me.Enabled = False
Else
If GeneralDialog(DIATYPE_OPERATORQ, Me.Caption, _
"Weet u zeker dat u de geselecteerde productieorders wilt verwijderen?", "") = _
' this says "are you sure that you want to delete the selected orders?"
DIABUTTON_YES Then
ReDim arrCurrentSelection(grdDataGrid.RowSel - 1)
lNumberCurrentlySelected = grdDataGrid.RowSel
For iCnt = 0 To grdDataGrid.RowSel - 1
arrCurrentSelection(iCnt) = grdDataGrid.RowSel = (iCnt)
Next iCnt
' definieer hoogste en de laagste selectie plus de selectiegrootte
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
For iCnt = LBound(arrCurrentSelection) To UBound(arrCurrentSelection)
[I][B] rs.Bookmark = arrCurrentSelection(iCnt)[/B][/I] 'This is the line that the program has trouble with
If rs![OpdrachtId] < lBeginSelect Then 'lager dan de vorige waarde?
lBeginSelect = rs![OpdrachtId]
End If
If rs![OpdrachtId] > lEindeSelect Then ' hoger dan de vorige
lEindeSelect = rs![OpdrachtId]
End If
Next iCnt
'OMM 6-10-2000; Gewijzigd om alleen de Orders te selecteren
Set rsSelect = gdbsMainDB.OpenRecordset( _
"SELECT * FROM ProductieOrders WHERE IsOrder = True ")
rsSelect.FindFirst "OpdrachtId=" & lBeginSelect
Do While (Not rsSelect.EOF) _
And (lBeginSelect <= lEindeSelect)
'OMM 17-7-2000; Veranderd voor AS400 Koppeling
' alleen rsSelect.Delete bestond
If CheckProductieOrderHasCharge(rsSelect![bonnummer]) Then
rsSelect.Edit
rsSelect![IsVerwijderd] = True
rsSelect.Update
Else
rsSelect.Delete
End If
rsSelect.MoveNext
lBeginSelect = lBeginSelect + 1
Loop
iSelectRegel = 1 ' New Id for the first Order
' Eerst renumber
rsSelect.MoveFirst
Do While Not rsSelect.EOF
rsSelect.Edit
rsSelect![OpdrachtId] = iSelectRegel
rsSelect.Update
rsSelect.MoveNext
iSelectRegel = iSelectRegel + 1
Loop
rsSelect.Close
rs.Update
End If
End If
End If
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 7th, 2002, 05:16 AM
#8
Redimming until the last selected row ? Does this work if the last row is at the top?
Also what is the type of array? Boolean?
Was there a collection of selected rows on the HFlexgrid?
The bit below in italic is probably wrong
and if it does what I am guessing its setting the array to
0 (false) or -1 (true) and you can't have a negative bookmark...
Try taking out the '='
Originally posted by WiseGuy
VB Code:
ReDim arrCurrentSelection(grdDataGrid.RowSel - 1)
lNumberCurrentlySelected = grdDataGrid.RowSel
For iCnt = 0 To grdDataGrid.RowSel - 1
arrCurrentSelection(iCnt) = [i]grdDataGrid.RowSel = (iCnt)[/i]
Next iCnt
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 7th, 2002, 05:23 AM
#9
Thread Starter
Lively Member
Well, if I take out the '=' than I get an compilation error which says 'Wrong number of arguments or invalid property assignment'.
The arrCurrentSelection is a Variant (whatever that is) and
lNumberCurrentlySelected is Long
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 7th, 2002, 05:36 AM
#10
Hi,
Ok asuming the first column holds the Records ID, you need to store this into the array.
Variant - means it can be any type and won't error... so could be a string or a number, or an object, etc. Uses more memory though because the program doesn't know what type to expect.
What you are trying to do is flag all the records in the table that have been selected. Then see if they have charge records.
One way is to create a flag field, use an executeable query to set it to false. Then for those selected set that field to true. Then perform the charge checks, flagging into the field appropriate (the approved field?). the execute a query to delete all those flagged in the first field mentioned that don't have the approved field set to true.
The other is the way its coded so far. There are again several approaches.
If there is no collection of selected (which would only hold those rows of the flexgrid that have been selected) then you need to loop through all entries of the flexgrid...
VB Code:
Dim lngLoop as long, lngMaxReturned as long
Dim aryIDs() as long
lngMaxReturned=0
'---- loop through all rows in the flex grid and save to the array
'---- only those we want (the selectedones)
For lngLoop = 0 to flexgrid.rows-1
If flexgrid.rowsel(lngloop) then
Redim Preserve aryIDs(lngMaxreturned)
aryIDs(lngMaxReturned)=CLng(flexgrid.textmatrix(lngLoop,0))
lngMaxReturned=lngMaxReturned+1
End if
Next
This assumes that it is Long type ids being returned and are held in the first column (0) which is probably invisible...
The preserve SHOULD preserve the existing array elements and since you are only adding won't affect them 
Lemme know ok?
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 7th, 2002, 06:20 AM
#11
Thread Starter
Lively Member
Originally posted by Ecniv
VB Code:
Dim lngLoop as long, lngMaxReturned as long
Dim aryIDs() as long
lngMaxReturned=0
'---- loop through all rows in the flex grid and save to the array
'---- only those we want (the selectedones)
For lngLoop = 0 to flexgrid.rows-1
If flexgrid.rowsel(lngloop) then
'for some reason this doesn't work I get the same error I got before: 'Wrong number of arguments or invalid property assignment'
Redim Preserve aryIDs(lngMaxreturned)
aryIDs(lngMaxReturned)=CLng(flexgrid.textmatrix(lngLoop,0))
lngMaxReturned=lngMaxReturned+1
End if
Next
Vince
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 7th, 2002, 07:04 AM
#12
hmmmm
Ok two things..
1) put the editting cursor over rowsel and hit f1.... that should tell you the parameters
2) change rowsel to selected or selection again hit f1 and see what the help says.
It might be selected, in which case it'll work ok 
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 7th, 2002, 07:38 AM
#13
Thread Starter
Lively Member
Okey, I got a little further again 
But now I hang on this line:
rs.Bookmark = arrCurrentSelection(iCnt)
I don't even know what it does.
I'm sorry I'm such a slow learning person but normally I'm not a programmer. I've been using VB for a month now! without any books 
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 7th, 2002, 08:11 AM
#14
(1)
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
For iCnt = LBound(arrCurrentSelection) To UBound(arrCurrentSelection)
rs.Bookmark = arrCurrentSelection(iCnt) 'This is the line that the program has trouble with
If rs![OpdrachtId] < lBeginSelect Then 'lager dan de vorige waarde?
lBeginSelect = rs![OpdrachtId]
End If
If rs![OpdrachtId] > lEindeSelect Then ' hoger dan de vorige
lEindeSelect = rs![OpdrachtId]
End If
Ok so you are here. Again (see three or four posts before ) But the difference is you have an array of IDs which were selected. Correct ?
If you have a little time spare and several (appropriated) sheets of a4 paper (from the printer ) I'd flow chart what the progarm is meant to do. Then you know how to change it 
The code quoted above appears to reset the beginning and end IDs if the current records (the one you moved to on the bookmark) ID is smaller or larger respectively.
Since your array has the IDs in question (all the selected ones) You could mimic the above code by loopign through your array and comparing the beginning and end numbers and change them as appropriate.
However, perhaps looking at why the original programmer was moving the end and beginning ids...
(2)
Set rsSelect = gdbsMainDB.OpenRecordset( _
"SELECT * FROM ProductieOrders WHERE IsOrder = True ")
rsSelect.FindFirst "OpdrachtId=" & lBeginSelect
Do While (Not rsSelect.EOF) _
And (lBeginSelect <= lEindeSelect)
'OMM 17-7-2000; Veranderd voor AS400 Koppeling
' alleen rsSelect.Delete bestond
If CheckProductieOrderHasCharge(rsSelect![bonnummer]) Then
rsSelect.Edit
rsSelect![IsVerwijderd] = True
rsSelect.Update
Else
rsSelect.Delete
End If
rsSelect.MoveNext
lBeginSelect = lBeginSelect + 1
Loop
This is the next section. Here you open the records and find the first ID (beginning value) then keep looping until the beginning value is greater than or equal to the end value.
Why bother with the top bit (1) though ? You don't need it so get rid of it. All you need to do is find each one of the selected (held in the array) and check that they can either be deleted or have a field set to true - (2) -
What the programmer has assumed is that the flexgrid will be populated IN ORDER by the ID. So your array should hold all the IDs in ascending order. If this is the case, then you need to change (2) to something like the following :
VB Code:
Set rsSelect = gdbsMainDB.OpenRecordset( _
"SELECT * FROM ProductieOrders WHERE IsOrder = True ")
For lngLoop = 0 to lngMaxReturned-1
rsSelect.FindFirst "OpdrachtId=" & aryIDs(lngLoop)
'OMM 17-7-2000; Veranderd voor AS400 Koppeling
' alleen rsSelect.Delete bestond
If CheckProductieOrderHasCharge(rsSelect![bonnummer]) Then
rsSelect.Edit
rsSelect![IsVerwijderd] = True
rsSelect.Update
Else
rsSelect.Delete
End If
Next
And remember I don't like using this method - but if it works use it until your coding style changes 
Note: This assumes that there are records there to find, if you are in a multi user there is a chance they could be deleted...
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 8th, 2002, 02:31 AM
#15
Thread Starter
Lively Member
Hi there,
it took me quite a long while before I understood what you wrote.
And I still don't get it all.
I've made the adjustments you said I should. But it still doesn't work. I still get the error in the first part.
Maybe I should completely understand the code first and see what it does but I don't have the experience to do that. It would take me weeks to find that out.
But it's propably just an syntax error If you could just tell me excactly what these lines do:
VB Code:
For iCnt = LBound(arrCurrentSelection) To UBound(arrCurrentSelection)
rs.Bookmark = arrCurrentSelection(iCnt) '<----- ERROR!!
If rs!OpdrachtId < lBeginSelect Then
lBeginSelect = rs![OpdrachtId]
End If
Or maybe you know what the correct syntax is?
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 8th, 2002, 02:40 AM
#16
Thread Starter
Lively Member
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 8th, 2002, 03:04 AM
#17
Hi,
Lets see if I can make it clearer (or muddy the water)
Flowchart - well no need to do the whole project, just the parts that interact with this particular problem 
The delete button does the following (Currently):
- Checks the bookmarks (all those selected) If the count is 0 then, creates the parameters, it opens the next form
Otherwise - Ask a question, if the answer is Yes, then create an array of all the IDs selected (via bookmarks)
- It then finds out each of the selected IDs and compares them against the start loop number (Beginning) and end number ID - If they are different, change them so the selected IDs are all included
- Now starting at the Beginning number, loop through the records and check whether the Order charge has been applied. If it has, set a field to true...If not then delete
- Increment the Beginning number and repeat above until either there are no records (EOF) or the beginning is greater than or equal to the end number.
- All existing records are then renumbered back into order.
Unfortunately whoever did this didn't account for the program checking ALL IDs between the highest and lowest, even if they weren't selected.
So, you change it to ADO. You FORGET bookmarks, because as you stated, they aren't used in ADO.
Now, I've simplified the process (above), so now we need to change it to allow you to use a flexgrid.
I assume you are filling the flexgrid via code and using Order By the ID field.
- Loop through ALL rows and find out which are selected. Store the ID numbers into an array
- Using this array, we open the recordset (again in order) and move to the ID in the first entry of the array
- Then check whether there is a charge - if there is -> update the validated field - - - If not -> Delete
- Once the For...Next loop has completed, you will need to refresh/requery the flexgrid...
Set rsSelect = gdbsMainDB.OpenRecordset("SELECT * FROM ProductieOrders WHERE IsOrder = True ")
For lngLoop = 0 to lngMaxReturned-1
rsSelect.FindFirst "OpdrachtId=" & aryIDs(lngLoop)
'OMM 17-7-2000; Veranderd voor AS400 Koppeling
' alleen rsSelect.Delete bestond
If CheckProductieOrderHasCharge(rsSelect![bonnummer]) Then
rsSelect.Edit
rsSelect("IsVerwijderd") = True
rsSelect.Update
Else
rsSelect.Delete
End If
Next
Hope that helps - if not lemme know.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 8th, 2002, 05:08 AM
#18
Thread Starter
Lively Member
Hmm still can't get it to work. Maybe I should completely rewrite the code, but the problem is that I'm not experienced enough.
An other option for me is to do it in small steps so first step is to delete just one record. Could you help me with that?
WiseGuy
P.S. here's what I have now, it runs without errors but nothing is deleted:
VB Code:
If rs.RecordCount <> 0 Then
If grdDatagrid.RowSel <= 0 Then
gsFormParm = CMD_DELRCD & "|" & rs![OpdrachtId]
frmProductieOpdrachten.Show
Me.Enabled = False
Else
If GeneralDialog(DIATYPE_OPERATORQ, Me.Caption, _
"Weet u zeker dat u de geselecteerde productieorders wilt verwijderen?", "") = _
DIABUTTON_YES Then
'ReDim arrCurrentSelection(grdDatagrid.RowSel - 1)
'lNumberCurrentlySelected = grdDatagrid.RowSel
'For iCnt = 0 To grdDatagrid.RowSel - 1
' arrCurrentSelection(iCnt) = grdDatagrid.RowSel
'Next iCnt
' definieer hoogste en de laagste selectie plus de selectiegrootte
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
' For iCnt = LBound(arrCurrentSelection) To UBound(arrCurrentSelection)
' rs.Bookmark = arrCurrentSelection(iCnt)
' If rs!OpdrachtId < lBeginSelect Then 'lager dan de vorige waarde?
' lBeginSelect = rs![OpdrachtId]
' End If
' If rs![OpdrachtId] > lEindeSelect Then ' hoger dan de vorige
' lEindeSelect = rs![OpdrachtId]
' End If
'Next iCnt
'OMM 6-10-2000; Gewijzigd om alleen de Orders te selecteren
For lngLoop = 0 To lngMaxReturned - 1
rsSelect.Find "OpdrachtId=" & aryIDs(lngLoop)
' If CheckProductieOrderHasCharge(rsSelect![bonnummer]) Then
' rsSelect.Update
' rsSelect!IsVerwijderd = 1
' rsSelect.Update
' Else
rsSelect.Delete
' End If
Next
iSelectRegel = 1 ' New Id for the first Order
' Eerst renumber
'rsSelect.MoveFirst
Do While Not rsSelect.EOF
rsSelect.Update
rsSelect![OpdrachtId] = iSelectRegel
rsSelect.Update
rsSelect.MoveNext
iSelectRegel = iSelectRegel + 1
Loop
rsSelect.Close
'rs.Update
End If
End If
End If
B.T.W. here's another thing I don't understand:
' If rs!OpdrachtId < lBeginSelect Then
' lBeginSelect = rs![OpdrachtId]
' End If
' If rs![OpdrachtId] > lEindeSelect Then
' lEindeSelect = rs![OpdrachtId]
' End If
I can't figure out where lBeginSelect and lEindeSelect is filled. asside from:
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
I'm sorry if I'm such a pain in the ass and I want you to know that I appreciate it very much that you are trying to help me out!
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 8th, 2002, 05:20 AM
#19
Originally posted by WiseGuy
VB Code:
[b]Use EOF not record count[/b]
If not rs.EOF Then
[b]1) You need to have a count of how many have been
selected... I can't remember if there is selcount..?[/b]
If grdDatagrid.RowSel <= 0 Then
gsFormParm = CMD_DELRCD & "|" & rs![OpdrachtId]
frmProductieOpdrachten.Show
Me.Enabled = False
Else
If GeneralDialog(DIATYPE_OPERATORQ, Me.Caption, _
"Weet u zeker dat u de geselecteerde productieorders wilt verwijderen?", "") = _
DIABUTTON_YES Then
'ReDim arrCurrentSelection(grdDatagrid.RowSel - 1)
'lNumberCurrentlySelected = grdDatagrid.RowSel
'For iCnt = 0 To grdDatagrid.RowSel - 1
' arrCurrentSelection(iCnt) = grdDatagrid.RowSel
'Next iCnt
' definieer hoogste en de laagste selectie plus de selectiegrootte
[b]2) See below[/b]
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
' For iCnt = LBound(arrCurrentSelection) To UBound(arrCurrentSelection)
' rs.Bookmark = arrCurrentSelection(iCnt)
' If rs!OpdrachtId < lBeginSelect Then 'lager dan de vorige waarde?
' lBeginSelect = rs![OpdrachtId]
' End If
' If rs![OpdrachtId] > lEindeSelect Then ' hoger dan de vorige
' lEindeSelect = rs![OpdrachtId]
' End If
'Next iCnt
'OMM 6-10-2000; Gewijzigd om alleen de Orders te selecteren
[b]
3) What does CheckProductieOrderHasCharge do?
I should just check using the ID to another linked table
(my guess) which could actuall be done here using a left join
- possibly...
Also need a check that the ID has been found...
[/b]
For lngLoop = 0 To lngMaxReturned - 1
rsSelect.Find "OpdrachtId=" & aryIDs(lngLoop)
If CheckProductieOrderHasCharge(rsSelect("bonnummer")) Then
rsSelect.Update
rsSelect!IsVerwijderd = 1
rsSelect.Update
Else
rsSelect.Delete
End If
Next
[b]4) Renumbers Ids[/b]
iSelectRegel = 1 ' New Id for the first Order
' Eerst renumber
rsSelect.MoveFirst
Do While Not rsSelect.EOF
rsSelect.Update
rsSelect![OpdrachtId] = iSelectRegel
rsSelect.Update
rsSelect.MoveNext
iSelectRegel = iSelectRegel + 1
Loop
rsSelect.Close
End If
End If
End If
B.T.W. here's another thing I don't understand:
All this does is set the beginning pointer to the end and the
end pointer to the beginning. Then as you loop through it moves
the beginning pointer to the smallest ID and the End poitner to
the largest ID. As I pointed out in my previous post, this is a bad
way of doing it as it does ALL the IDs between the beginning and
end ids, not just those selected...
I can't figure out where lBeginSelect and lEindeSelect is filled. asside from:
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
' If rs!OpdrachtId < lBeginSelect Then
' lBeginSelect = rs![OpdrachtId]
' End If
' If rs![OpdrachtId] > lEindeSelect Then
' lEindeSelect = rs![OpdrachtId]
' End If
I'm sorry if I'm such a pain in the ass and I want you to know that I appreciate it very much that you are trying to help me out!
Me? Or the previous coder hehhehehe
I bet you don't wanna meet them now 
If you understand what its doing it would probably be best if you rewrote in your own code, as you'd know what its doing.
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 8th, 2002, 07:24 AM
#20
Thread Starter
Lively Member
Grrrr still doesn't work (not mad at you )
Here's the code I have now. I've checked but there is no such thing as selcount.
But even if there was where excactly should I put or replace it?
Oh and about the left Join, I believe that's Acces but this program
needs to chat with an Oracle DB
VB Code:
If Not rs.EOF Then
gsFormParm = CMD_DELRCD & "|" & rs![OpdrachtId]
frmProductieOpdrachten.Show
Me.Enabled = False
Else
If GeneralDialog(DIATYPE_OPERATORQ, Me.Caption, _
"Weet u zeker dat u de geselecteerde productieorders wilt verwijderen?", "") = _
DIABUTTON_YES Then
ReDim arrCurrentSelection(grdDatagrid.RowSel - 1)
lNumberCurrentlySelected = grdDatagrid.RowSel
For iCnt = 0 To grdDatagrid.RowSel - 1
arrCurrentSelection(iCnt) = grdDatagrid.RowSel
Next iCnt
lBeginSelect = DEF_MAXNBR_PRODUCTIEORDERS + 1
lEindeSelect = 0
For lngLoop = 0 To lngMaxReturned - 1
rsSelect.Find "OpdrachtId=" & aryIDs(lngLoop)
If CheckProductieOrderHasCharge(rsSelect("bonnummer")) Then
rsSelect.Update
rsSelect!IsVerwijderd = 1
rsSelect.Update
Else
rsSelect.Delete
End If
Next
iSelectRegel = 1
rsSelect.MoveFirst
Do While Not rsSelect.EOF
rsSelect.Update
rsSelect!OpdrachtId = iSelectRegel
rsSelect.Update
rsSelect.MoveNext
iSelectRegel = iSelectRegel + 1
Loop
rsSelect.Close
End If
End If
Right now it keeps on hanging on the rsSelect.movenext line
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 8th, 2002, 11:45 AM
#21
So the records were updated correctly before that?
Any error message or just stops working?
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 8th, 2002, 11:51 AM
#22
VB Code:
lNumberCurrentlySelected = 0
For iCnt = 0 To grdDatagrid.Rows - 1
If grdDataGrid.RowSel(iCnt) then
arrCurrentSelection(INumberCurrentlySelected) = grdDatagrid.textmatrix(iCnt,0)
INumberCurrentlySelected=INumberCurrentlySelected + 1
End If
Next iCnt
In response to the count bit
I suggest that you use the remarks in your coding (with the single quote) and break it up into sections so if you need to look at it again in the future you'll know what you did 
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 13th, 2002, 03:54 AM
#23
Thread Starter
Lively Member
Could this line:
If grdDataGrid.RowSel(iCnt) then
also be done like this:
If grdDataGrid.RowSel = (iCnt) Then
or is that something completely different? When I use the first line it gives the error "Wrong number of arguments or invalid property assignment"
And when I use the second line it gives an error on the line:
rsSelect.MoveFirst
wich says: "Method 'MoveFirst of object'_Recordset' failed"
Any Ideas?
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 13th, 2002, 04:17 AM
#24
Hmm microsoft site doesn't seem to be working from here and I don't have vb to hand...
What does the help say about RowSel ?
Stoopid network here at work...
I don't remember there being a Selected property, otherwise I would say it was something like : Flex.Row(iCnt).Selected
If MS gets up I'll browse the msdn libs and let you know ok..
Vince
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 13th, 2002, 04:25 AM
#25
Thread Starter
Lively Member
Here's what Help has to say about RowSel
Syntax
object.ColSel [= value]
object.RowSel [= value]
Syntax for the ColSel and RowSel properties has these parts:
Part Description
object Anobject expression that evaluates to an object in the Applies To list.
value ALong value that specifies the start or end row, or column, for a range of cells.
Remarks
You can use these properties to select a specific region of the MSHFlexGrid programmatically, or to read the dimensions of an area that the user selects into code.
The MSHFlexGrid cursor is in the cell at Row, Col. The MSHFlexGrid selection is the region between rows Row and RowSel and columns Col and ColSel. Note that RowSel may be above or below Row, and ColSel may be to the left or to the right of Col.
Whenever you set the Row and Col properties, RowSel and ColSel are automatically reset, so the cursor becomes the current selection. To select a block of cells from code, you must first set the Row and Col properties, and then set RowSel and ColSel.
I don't remember there being a Selected property, otherwise I would say it was something like : Flex.Row(iCnt).Selected
He recognizes it but doesn't work, I get the same error:
"Wrong number of arguments or invalid property assignment"
What's the addres of the MS MSDN librarys, I could take a peek myself sometimes 
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 13th, 2002, 04:40 AM
#26
M S D N - a search
Basically, www.microsoft.com then use the search... putting msdn as the first search parameter 
I have thought of another way around, but you might not like it...
It uses and array of boolean, one for each row. As the user clicks the array is updated (either all to true ot flips the boolean). Then when you need to find all the selected rows you go through the array. Just a thought, back up plan just incase 
Vince
Still wading through MSDN online....
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 13th, 2002, 04:51 AM
#27
Thread Starter
Lively Member
I don't have any problems getting on the MSDN libs.....
About the workaround................................................. I'll have to think about that 
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 13th, 2002, 05:22 AM
#28
Have a look and see if there is a property called - ItemsSelected
If there is everything is solved... but seeing as that would be easy there probably isn't 
MSDN Helpfiles on MSHFlexgrid
Vince
Last edited by Ecniv; May 13th, 2002 at 05:29 AM.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
May 13th, 2002, 05:31 AM
#29
Thread Starter
Lively Member
Originally posted by Ecniv
Have a look and see if there is a property called - ItemsSelected
I assume you meant a property of the MSHFlexGrid? Then no there isn't, If you meant something else lemmeno
If there is everything is solved... but seeing as that would be easy there probably isn't
It's allways like that right? sigh........
Vince
WiseGuy
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
-
May 15th, 2002, 03:06 AM
#30
Thread Starter
Lively Member
Well still can't get it to work properly, I think I'll start working on the backup plan you suggested :
I have thought of another way around, but you might not like it...
It uses and array of boolean, one for each row. As the user clicks the array is updated (either all to true ot flips the boolean). Then when you need to find all the selected rows you go through the array. Just a thought, back up plan just incase
WiseGuy
P.S. thank you very much for trying to help me
I stuck my head out of the window and got arrested for mooning!
This Post is sponsored by my PC: PIII900, 512MBDimm/133, Seagate 40GB/7200 ATA100, LiteOn 12x DVD, Lite-On 32x12x40 CDrw, Elsa Geforce2 Ultra 64MB incl tv-out, SoundBlaster Live 1024, Ilyama A702HT Vision Master Pro410 17".
O/S: Windows XP Professional (dutch)
Internet: Cable (1Mbit connection)
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
|