Welcome to Forums Sign in | Join | Help | Forums
in Search





Make the world a better place.

Using grids on VBA forms

Last post 06-19-2008 7:40 PM by Steven Cinquegrana. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-13-2004 11:11 AM

    Using grids on VBA forms

    Has anyone successfully included a grid in their own VBA form? I am considering building a new form for a user that would require a grid and would love some advice on which grid to use (or avoid). Thanks, Eric Aldrich tech2 - at - northwestharvest.com
  • 03-03-2005 11:22 AM In reply to

    Using grids on VBA forms

    I have had success in using it. I am making a user interface that allows users to add orders to re7. I have used the the RESupergrid70EX datagrid to display benefits and also credit card info. I believe most of the forms throughout the program use this one. I am not sure if I am loading them with data the same way that bb programmers would advise (since I have seen no examples), but they work for me. There are also some "preloaded" grids that only require instantiation of the object (for example the attributes or phone grid) which makes for less coding. Let me know what kind of example you would like to see.
  • 03-09-2005 11:24 AM In reply to

    Using grids on VBA forms

    I would love to see an example using the RESupergrid70EX. You can email it to me at [Email Removed]. Thanks a lot. Eric Aldrich
  • 03-09-2005 11:27 AM In reply to

    Using grids on VBA forms

    I would like to see your examples too! Thanks David [Email Removed]
  • 03-09-2005 12:37 PM In reply to

    Using grids on VBA forms

    Here is an example on how to load the grid. I have pulled the example from my code, which makes use of the benefits table. I understand that not all people may use/have items entered in the benefits table (in which case, you will need to see the below example as simply an analogy since it will not work with your setup). If you desire a more specific example with regard to the particular goal you had in mind, let me know... This example ONLY shows how to load the grid. You need to create other functions that run off of the grid's events so that the grid performs all the specific actions that you want it to perform. For example, I have further functions that tell the grid to fill in the rest of a row with other data when the user selects from the column1 combobox, calculate another column's amount when the user changes the quantity, add a new blank row after the user fills in a row, etc. FYI,the right-click contextmenu is not automatically added to the grid when you right-click a row (for operations such as delete/insert a row). You need to create a menu and add it to the grid to have that functionality. I am trying to make progress on that now, but re7 is having serious issues about running the code since it locks up. I have found no examples on how to instantiate the bbmenu control and add it to objects, so I hope that I can figure something out. [red]Do the following things first:[/red] [list] [*]insert a new UserForm [*]add a SuperGrid70Ex grid to the form (right click on the toolbox, click additional controls, and search for the control in the list in order to add it to your tool palette. [*]insert the following code for the form (rightclick on form name and select view code) [*]type userform1.show in the immediate window to run the script [/list] [code] Private Sub UserForm_Activate() ''HOW TO LOAD THE SUPERGRID70EX1 GRID...THE FOLLOWING IS AN ANALOGY TO LOADING THE GRID ''YOU CAN SUBSTITUTE OTHER DATA TO LOAD INTO THE GRID FROM EITHER THE RE7 TABLES ''OR YOUR OWN SPECIFIC DATASET ''STEP 1: DESIGNATE THE COLUMN HEADING NAMES|SIZES|COLUMN TYPES|ALIGNMENTS|ETC. With SuperGrid70Ex1 .addColumn "Benefit", 275, sgcCombo, selAlignLeft, selAlignLeft, False, sgSortString .addColumn "Count", 50, sgcAmount, selAlignCenter, selAlignCenter, False, sgSortString .addColumn "Line Total", 65, sgcAmount, selAlignCenter, selAlignCenter, False, sgSortString .addColumn "Comments", 300, sgcEdit, selAlignLeft, selAlignLeft, False, sgSortString ''STEP 2: INSERT A BLANK ROW .InsertRow 4 End With ''STEP 3: LOAD THE GRID *DIRECTLY* FROM A RE7 TABLE Dim moREService As REServices Set moREService = New REServices Dim moCodeTablesServer As CCodeTablesServer moREService.Init REApplication.SessionContext Set moCodeTablesServer = moREService.CreateServiceObject(bbsoCodeTablesServer) moCodeTablesServer.Init REApplication.SessionContext ''THE FOLLOWING LINE LOADS THE FIRST COLUMN (COMBOBOX) WITH THE DATASET FROM THE BENEFITS TABLE ''YOU CAN CHOOSE OTHER TABLES OTHER THAN TBNUMBENEFITS...INTELLISENSE SHOULD PROVIDE YOU WITH THE CONSTANTS FOR THEIR NAMES moCodeTablesServer.LoadSuperGridCombo SuperGrid70Ex1, 1, tbnumBenefits, False, True, True moREService.CloseDown Set moREService = Nothing ' ''ALTERNATE OPTION FOR STEP 3 ' ''STEP 3: LOAD THE GRID MANUALLY SO THAT YOU CAN OMIT CERTAIN ITEMS FROM THE DATASET OR ' ''TO PERFORM OTHER OPERATIONS ON THE DATASET BEFORE DISPLAYING IT ' ''I USE THE EXAMPLE BELOW TO OMIT THOSE BENEFIT ENTRIES THAT I DO NOT WANT THE USER TO SEE ' Dim booBenefitActive As Boolean ' Dim strBenefitDescription As String ' Dim curBenefitAmount As Currency ' Dim oEntry As CTableEntry ' Dim oEntries As CTableEntries ' Set oEntries = New CTableEntries ' oEntries.Init REApplication.SessionContext ' ' For Each oEntry In oEntries ' ''FIND THE TABLE ENTRIES FOR THE TABLE YOU NEED ' If oEntry.TableNumber = tbnumBenefits Then ' booBenefitActive = oEntry.Fields(tableentry_fld_ACTIVE) ' strBenefitDescription = oEntry.Fields(tableentry_fld_LONGDESCRIPTION) ' ''SET THE PRODUCT AMOUNT TO 0 IF IT HAS NO USABLE CURRENCY VALUE ' If oEntry.Fields(tableentry_fld_NumericVALUE) = "" Then ' oEntry.Fields(tableentry_fld_NumericVALUE) = 0 ' End If ' curBenefitAmount = oEntry.Fields(tableentry_fld_NumericVALUE) ' ''ADD VALUES TO COMBO BOX WHILE OMITTING UNNECESSARY ONES ' If (booBenefitActive = True) And _ ' (strBenefitDescription <> "Additional Fees") And _ ' (strBenefitDescription <> "Express Delivery Fee") And _ ' (strBenefitDescription <> "International Shipping Fee") And _ ' (strBenefitDescription <> "Sales Tax") And _ ' (strBenefitDescription <> "Shipping/Handling") Then ' ''HERE IS WHERE WE ARE ADDING A ROW AS LONG AS IT IS NOT ONE OF THE ABOVE UNWANTED ENTRIES ' ''THAT IS, BY THE .ADDCOMBOITEM METHOD. HERE I AM HIDING THE BENEFIT AMOUNT IN THE DATA PORTION OF ' ''THE COMBO LIST SO THAT I CAN PERFORM CALCULATIONS ON IT WHEN A USER SELECTS A BENEFIT FROM THE LIST ' SuperGrid70Ex1.AddComboItem 1, strBenefitDescription, curBenefitAmount ' End If ' End If ' oEntry.CloseDown ' Next oEntry ' SuperGrid70Ex1.SetFocus ' oEntries.CloseDown ' Set oEntries = Nothing ' Set oEntry = Nothing End Sub [/code] [i]--- Edited at 3/9/2005 12:48:45 PM by Kirk Vukonich[/i] [i]--- Edited at 3/9/2005 12:51:30 PM by Kirk Vukonich[/i]
  • 01-09-2006 6:47 AM In reply to