Solved

VB6 multiple selections from msflexgrid to array with checks

Posted on 2007-03-29
5
490 Views
Last Modified: 2013-12-20
Hi,

Our inhouse software covers invoice registration amongst other things. (Visual Basic 6)
Operational people enter their expected costs on a per file basis.
When the actual invoice arrives, the finance department registers the invoice in their part of the system, then matches the "expected costs" entered by the operational people to the actual invoice.

At the moment the finance users can only select one line at a time and the confirm.
I would like them to be able to match multiple lines in one go.
The selections are made from a msflexgrid.

To start with I created:
Private Type RowsToValidate
   DetID as long ' ID of the expected costs table
   RegNr as long ' The invoice registration number
   FlexRowNr as Byte ' Flex line nr ' Don't know if this is even necessary
End Type
Dim ValRows() as RowsToValidate 'Rows to confirm

When the user clicks on the flex to make the selection I would like:
A check to see if it has already been selected. If so remove it from the array (Deselect)
If it hasn't been selected I want to add it to the array.

Once the user has made all the selections they want, they will click on a button to do the confirmation (Validation)
This will be done by a function. For this to work i'll need to know how many values are in the array.
Can I use something like:
FOR i = 0 to max(Array) ????
or should I use the recordset count from the rs used to fill the flex in the first place???

As this is the first time I have worked with types, arrays and multiple selections on flexgrids, I am having a trouble getting my head around the logic needed and the steps involved.

Thanks in advance for any help you can offer.






0
Comment
Question by:DennisPost
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:TreyH
ID: 18815723
Will the selections be contiguous or non-contiguous?
The MSHFlexGrid by design does not offer multiple non-contiguous cell selection. You would probably have to investigate a 3rd party control to do that.
0
 
LVL 2

Author Comment

by:DennisPost
ID: 18816261
Hi TreyH,

That's some bad news as they will be non-contiguous.
I just finished another sub to allow the users to validate all available "excpected costs". :

dim i as integer
    'Fill the array with values from the recordset
    i = 1
    rsInvLines.MoveFirst
    Do While rsInvLines.EOF = False
        ValRows(i).DetID = rsInvLines!DetID
        ValRows(i).RegNr = Me.txtNum
        i = i + 1
        rsInvLines.MoveNext
    Loop
   
    'Cycle through the array calling the function ValidateRows each time
    For i = 1 To intRSRows
        ValidateRows ValRows(i).DetID, ValRows(i).RegNr
    Next i

This will suffice,
but I would still like to realize my question.

I will try some of these EE checkbox in flexgrid answers.
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_21737329.html
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20803581.html
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_11819218.html
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_20313081.html

I you have a better idea, please don't be shy about letting know about it. :-)


0
 
LVL 6

Accepted Solution

by:
nirojexpert earned 500 total points
ID: 18923399
denispost,

you can use hidden columns to store the state of selections
for example
'while loading data set the first column;s visibility to off, rest columns contain your data.
with grid
.column(0).width=0
end with

'when user click to make selection, you can do as
if .textmatrix(.row, 0) = "" then 'no selection so far
   .col = 1
   set .cellPicture = loadPicture("C:\selected.gif")
 .text = 1
else
   .col = 1
   set .cellPicture = loadPicture("C:\notselected.gif")
 .text = 0
end if


'now to find the selected ones
selID = ""
with grid
  for i= 0 to .rows-1
     if .textmatrix(i,0) = 1 'this is a selected row
      if selID ="" then
               selID = .textMatrix(.row, 0)
      else
               selID = selID & .textmatrix(.row, 0)
      end if
   end if
  next i
end with
  idArray = split(selID, ",")


'so there is no restriction in how the user will make the selecetion
but the user has to click on the row to make the selection
0
 
LVL 2

Author Comment

by:DennisPost
ID: 18937598
Thanks Nirojexpert,

I am a little swamped with other higher priority work at the moment. I will try this out as soon as I can.

A few questions about your code though.
Where can I get these .gif files?
I assume SellID is just an integer value.
What kind of variable should the idArray be? Dim idArray() as String ??
I .col=1 contains the .text, this will not highlight the whole row then, right?
After I fill the idarray from Selid, how would I my array (ValidateRows ValRows(i).DetID, ValRows(i).RegNr)?

Thanks for your help!
0
 
LVL 6

Expert Comment

by:nirojexpert
ID: 18944210
A few questions about your code though.
Where can I get these .gif files? it can be any. instead of c:\ make a folder "images " where exe is built and then use the app.path & "\images\selected.gif"

I assume SellID is just an integer value. you put the ID of the record that will identify the record.
What kind of variable should the idArray be? Dim idArray() as String ??
I .col=1 contains the .text, this will not highlight the whole row then, right? . highlighting the whole row will depend on the property of grid.
After I fill the idarray from Selid, how would I my array (ValidateRows ValRows(i).DetID, ValRows(i).RegNr)? you will probably need to modify the function such that it can accept the whole array like ValidDateRows(Rows() ), etc
upload your code blocks, i will be able to help further
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Access 2016 VB code 9 103
Need VBS version of Excel date conversion 4 65
SSRS expression Issue finding a string 10 66
Add and format columns in vb6 7 47
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now