i able to fill one row of MSHFlexGrid form 6 textbox which i
assinged one by one. The problem is how to fill the next row coz
i want to fill about 100 row into my MSHFlexGrid form the same 6
textbox. Every time i add it will change the first row. I want
it to fill the next row. below is my coding:
Code:
Private Sub cmdAdd_Click()
Dim Iloop3 As Long
Dim R
Dim i As Integer
With MSHF2
.AddItem ""
.TextMatrix(.Row, 1) = txtMembership.Text
.TextMatrix(.Row, 2) = txtNamemem.Text
.TextMatrix(.Row, 3) = txtSandp.Text
.TextMatrix(.Row, 4) = txtNetprice.Text
.TextMatrix(.Row, 5) = txtStatus.Text
.TextMatrix(.Row, 6) = txtPremium.Text
End With
For Iloop3 = 0 To MSHF2.Rows - 1
MSHF2.TextMatrix(R, 0) = R
R = R + 1
Next
End Sub
Private Sub cmdAdd_Click()
Dim Iloop3 As Long
Static R
Dim i As Integer
With MSHF2
.AddItem ""
.TextMatrix(R, 0) = R ' might want to use R + 1
.TextMatrix(R, 1) = txtMembership.Text
.TextMatrix(R, 2) = txtNamemem.Text
.TextMatrix(R, 3) = txtSandp.Text
.TextMatrix(R, 4) = txtNetprice.Text
.TextMatrix(R, 5) = txtStatus.Text
.TextMatrix(R, 6) = txtPremium.Text
End With
R = R + 1
End Sub
I have tried that befor Mr.David. It still just update the first row and adding blank grid after the next add button click. Bellow is the whole coding of my project
Code:
Option Explicit
Private Sub cmdAdd_Click()
Dim Iloop3 As Long
Static R
With MSHF2
.AddItem ""
.TextMatrix(.Row, 0) = R
.TextMatrix(.Row, 1) = txtMembership.Text
.TextMatrix(.Row, 2) = txtPkg.Text
.TextMatrix(.Row, 3) = txtNamemem.Text
.TextMatrix(.Row, 4) = txtSandp.Text
.TextMatrix(.Row, 5) = txtNetprice.Text
.TextMatrix(.Row, 6) = txtStatus.Text
.TextMatrix(.Row, 7) = txtPremium.Text
.TextMatrix(.Row, 8) = txtMemid.Text
End With
R = R + 1
End Sub
Private Sub cmdBatch_Click()
Newbatch.Show
End Sub
Private Sub cmdexit_Click()
Unload Me
End Sub
Private Sub Form_Load()
Set cn = New ADODB.Connection
cn.Provider = "Microsoft.JET.OLEDB.4.0"
cn.ConnectionString = "Data Source = " & App.Path & "\BVCpbschm.mdb;" & "Persist Security Info = False"
cn.Open
MSHF1.ColWidth(0) = 200 'tepi
MSHF1.ColWidth(1) = 1500 'membership
MSHF1.ColWidth(2) = 200 'pkg
MSHF1.ColWidth(3) = 4000 'member name
MSHF1.ColWidth(4) = 1200 'sandp
MSHF1.ColWidth(5) = 900 'net price
MSHF1.ColWidth(6) = 1000 'status
MSHF1.ColWidth(7) = 1000 'status
MSHF2.ColWidth(0) = 500 'tepi
MSHF2.ColWidth(1) = 1500 'membership
MSHF2.ColWidth(2) = 200 'pkg
MSHF2.ColWidth(3) = 4000 'member name
MSHF2.ColWidth(4) = 1200 'sandp
MSHF2.ColWidth(5) = 900 'net price
MSHF2.ColWidth(6) = 1000 'status
MSHF2.ColWidth(7) = 1000 'premium
MSHF2.ColWidth(8) = 1000 'status
Combo1.AddItem "ESTEEM"
Combo1.AddItem "EXECUTIVE"
txtMembership.Enabled = False
txtPkg.Enabled = False
txtNamemem.Enabled = False
txtSandp.Enabled = False
txtNetprice.Enabled = False 'textbox control
txtStatus.Enabled = False
txtPremium.Enabled = True
End Sub
Private Sub MSHF1_Click()
If MSHF1 = "" Then
Exit Sub
Else
txtMembership.Text = MSHF1.TextMatrix(MSHF1.Row, 1)
txtPkg.Text = MSHF1.TextMatrix(MSHF1.Row, 2)
txtNamemem.Text = MSHF1.TextMatrix(MSHF1.Row, 3)
txtSandp.Text = MSHF1.TextMatrix(MSHF1.Row, 4)
txtNetprice.Text = MSHF1.TextMatrix(MSHF1.Row, 5)
txtStatus.Text = MSHF1.TextMatrix(MSHF1.Row, 6)
txtMemid.Text = MSHF1.TextMatrix(MSHF1.Row, 7)
txtPremium = ""
txtPremium.SetFocus
End If
End Sub
Private Sub Combo1_Click() 'Selecting the Database according the name
MSHF1.Clear
Select Case Combo1.Text
Case "ESTEEM"
Call esteem
Case "EXECUTIVE"
Call executive
End Select
End Sub
Private Sub esteem() 'creating connection for Case Advocaten
Set rs1 = New ADODB.Recordset
rs1.Open "SELECT membership,pkg,namemem,sandp,netprice,status,memberid FROM allmship WHERE (package='esteem')", cn, adOpenStatic, adLockPessimistic
Set MSHF1.DataSource = rs1
End Sub
Private Sub executive() 'creating connection for Case Advocaten
Set rs1 = New ADODB.Recordset
rs1.Open "SELECT membership,pkg,namemem,sandp,netprice,status,memberid FROM allmship WHERE (package='executive')", cn, adOpenStatic, adLockPessimistic
Set MSHF1.DataSource = rs1
End Sub
I fix the coding and my grid property and it work.
Code:
Private Sub cmdAdd_Click()
Dim Iloop3 As Long
Static R
With MSHF2
.AddItem ""
.TextMatrix(R, 1) = txtMembership.Text
.TextMatrix(R, 2) = txtPkg.Text
.TextMatrix(R, 3) = txtNamemem.Text
.TextMatrix(R, 4) = txtSandp.Text
.TextMatrix(R, 5) = txtNetprice.Text
.TextMatrix(R, 6) = txtStatus.Text
.TextMatrix(R, 7) = txtPremium.Text
.TextMatrix(R, 8) = txtMemid.Text
R = R + 1
End With
End Sub
I fix the coding and my grid property and it work.
Code:
Private Sub cmdAdd_Click()
Dim Iloop3 As Long
Static R
With MSHF2
.AddItem ""
.TextMatrix(R, 1) = txtMembership.Text
.TextMatrix(R, 2) = txtPkg.Text
.TextMatrix(R, 3) = txtNamemem.Text
.TextMatrix(R, 4) = txtSandp.Text
.TextMatrix(R, 5) = txtNetprice.Text
.TextMatrix(R, 6) = txtStatus.Text
.TextMatrix(R, 7) = txtPremium.Text
.TextMatrix(R, 8) = txtMemid.Text
R = R + 1
End With
End Sub
thanks for the above code, it was very helpful, No.1 site man for learner and beginners just like us . Thanks again to Mr. DAVID
Yes David is great!
Just remember this thread is 2 years old
Keep posting at this wonderful site Registered2009, if you have questions, don't hesitate in posting a New Thread about your topic, and you'll find out how many more great members post here
Bookmarks