You are on page 1of 13

` `

Start up VB with a standard Exe project. Go to project menu and select components or Ctrl+T) (fig).

` ` ` `

When we select components a dialog box appear and add:Microsoft FlexGrid control 6.0 From that dialog box.

` `

Now we will see the new tool populated in the toolbox can be shown in the toolbox (fig):Now change the name of the main form to frmflexgrid or any other name acording to our wish.

` `

`
` ` ` `

SET UP DATA CONTROL


Add Data grid to the form using the toolbox [ and draw it on the form. Now add MSFlexGrid control into the form.(fig) ]

And add combo box [

]in order to access the data.

`
` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` `

CONNECT TO DATA BASE


Now after all is done in the form let us begin the coding for accessing data from using combo box. Go to form and define the dimension as Dim DB As Database Dim RS As Recordset for our own convince it is not necessary but short name for Database. Go to the combo box code window and do coding as :Private Sub Combo1_CLICK() FG1.Clear FG1.TextMatrix(0, 0) = "ROLLN0" FG1.TextMatrix(0, 1) = "NAME" FG1.TextMatrix(0, 2) = "CLASS" FG1.TextMatrix(0, 3) = "DIVISION" FG1.TextMatrix(0, 4) = "TOTAL" FG1.TextMatrix(0, 5) = "PERCENT" X=1 Set RS = DB.OpenRecordset("SELECT * FROM BCA WHERE CLASS ='" + Trim(Combo1.Text) + "'") Do Until RS.EOF FG1.Rows = X + 1 FG1.TextMatrix(X, 0) = RS!ROLLNO FG1.TextMatrix(X, 1) = RS!Name FG1.TextMatrix(X, 2) = RS!Class FG1.TextMatrix(X, 3) = RS!DIVISION FG1.TextMatrix(X, 4) = RS!TOTAL FG1.TextMatrix(X, 5) = RS!Percent RS.MoveNext X=X+1 Loop End Sub

9. We have to sepecify the connection location to data Access for that purpose do coding upon the form load event as Private Sub Form_Load() Set DB = OpenDatabase("D:\BCA.MDB") Set RS = DB.OpenRecordset("SELECT DISTINCT CLASS FROM BCA") Do Until RS.EOF Combo1.AddItem RS!Class RS.MoveNext Loop End Sub 10.Save and run the project it will display in the following format and help us to show in a flexgrid with using data combo as it source. our data

` ` ` ` ` ` ` ` ` ` `

` `

1. Start up VB with a standard Exe project. 2. Go to project menu and select components (Ctrl+t) (figure). 3. Now add control to our project that is:Microsoft Data list control 6.0 (OLDEB) Then click apply and ok.(figure)

` `

3. Now we will see that toolbox is populated with two more icons as shown in the figure:4. Now change the property of the main form as :S.no i. ii. iii. Name Name Font Window Status Caption Frm_Datagrid Times new Roman (14) Maximize

SET UP DATA CONTROL


5. Add an ADO Data control to the form using the ADO DC tool [ as ADODC and change its Visible property to False. 6. Now right control and select ADODC Properties option from the shortcut menu that appers.(figure) ] and draw it on the form.Name it

7.

Now it will display property page (Figure) for the ADODC control that we added In our project . Select the source of the connection as use connection string and click build Button.

8. Now it will display another dialog DATA LINK PROPERTY pops up. Select Microsoft jet 3.51OLE DB Provider from the list and click next.(figure)

9. We have to sepecify the connection to data access. Select the data base name. and then click on test connection button. If the connection is properly connected to our ACCESS database then it will display the dialog box as text connection succeded.(fig)

10. Once all we have done then click OK on Data Link dialogbox and again in property page dialog.

11. Now once again in the property pages select the record source tab, set command type the source string which contain access statement. i.e. 2 adcmdTable

12. Table name this contain name of the access file. i.e.

command type Table name

2 - adcmdTable Employee Detail

12 .Now draw the data list into the form and set all the property of it as
S.NO

NAME DATA SOURCE ROWSOURCE LIST FEILD FONT

PROPERTY

01. 02. 03. 04.

ADODC1 ADODC1 (FIELD NAME) ARIAL (14)

13. After all is done save the form and create the start up object as our ok.

default form name click apply then

14. Run the form by clicking (f5) or by clicking start from the tool bar. It will display the form in this way.

You might also like