Help wanted!!
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Help wanted!!

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Angry Help wanted!!

    Dear Buddies,

    Hello, after a long time I entered this forum again.

    I have a peculiar question: that is

    I have a database with a table called NAME(apart from name field , there are SEx age ,Qlf,Address), there are several names in that Table some are duplicate name(I need these ) with different address,anyway I want MsFlexGrid1 to show the Duplicates I search for.
    StrSql1="Select * From table where name like '" & Me.cmbpid.text & "'"
    But this Flexgrid shows 1 record only.
    I want to see all 4 records saved in there.


    I did this:
    Code:
    Data1.RecordSource = "Select * from Master where name like '*" & Trim(ftext) & "*'"
    Data1.Recordset.MoveNext
    Data1.Refresh
    con.close
    strsql1 = "SELECT * FROM MASTER WHERE NAME LIKE '" & Me.cmbpid.Text & "'"
     
     With rs
        
        rs.ActiveConnection = con.ConnectionString
        .CursorLocation = adUseClient
        .Open strsql1
        If rs.RecordCount > 0 Then
        .MoveFirst
        k = .RecordCount
        
            For q = 1 To k
                'MSFlexGrid1.Clear
                MSFlexGrid1.AddItem (strsql1)
               
                'MSFlexGrid1.TextMatrix(1, 0) = .Fields(0)
                'MSFlexGrid1.TextMatrix(1, 1) = .Fields(1)  ' and so on for display
                'MSFlexGrid1.TextMatrix(1, 2) = .Fields(2)
                'MSFlexGrid1.TextMatrix(1, 3) = .Fields(3)
                'MSFlexGrid1.TextMatrix(1, 4) = .Fields(4)
                'MSFlexGrid1.TextMatrix(1, 5) = .Fields(5)
                'MSFlexGrid1.TextMatrix(1, 6) = .Fields(6)
                'MSFlexGrid1.TextMatrix(1, 7) = .Fields(7)
                'MSFlexGrid1.TextMatrix(1, 8) = .Fields(8)
                'MSFlexGrid1.TextMatrix(1, 9) = .Fields(9)
                'MSFlexGrid1.TextMatrix(1, 10) = .Fields(10)
                'MSFlexGrid1.TextMatrix(1, 11) = .Fields(11)
                'MSFlexGrid1.TextMatrix(1, 12) = .Fields(12)
                'MSFlexGrid1.TextMatrix(1, 13) = .Fields(13)
                'MSFlexGrid1.TextMatrix(1, 14) = .Fields(14)
                'MSFlexGrid1.TextMatrix(1, 15) = .Fields(15)
                Next
       If .EOF = True Then
               MsgBox (rs.RecordCount() & " Records presented.")
       End If
          yesno = MsgBox("See More", vbYesNo)
          If yesno = vbNo Then
          MSFlexGrid1.Clear
          End If
          .MoveNext
            '
        End If
        Set rs = Nothing
    
          On Error GoTo 0
    Exit Sub
    End With
    Last edited by WizBang; November 2nd, 2013 at 09:25 AM. Reason: Fixed code tags

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,860

    Re: Help wanted!!

    You have code there to clear the grid inside your loop. Move that line up to just before the For statement

    Your next is in the wrong place as well should be after the .movenext and both the .movenext and the next should be below the end if
    Last edited by DataMiser; November 1st, 2013 at 12:56 PM.
    Always use [code][/code] tags when posting code.

  3. #3
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,860

    Re: Help wanted!!

    Also note that yo use code tags you need to use []s rather than <>s
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Re: Help wanted!!

    Dear Friends,
    I have succeeded in rectifying the issue ,which I posted before.
    The next problem is:
    I can not keep the highlighter on to a specific record in MSFlexGrid1, it always jumps to the first Record.
    I need the Selected(Highlighted) record for doing changes or you can say make transactions & update that particular Record.
    This is now Highlighting the Specific Record, but I can not use that record for editing or doing any transactions.
    If the Record is single & unique (No other similar Items present) then That record gets modified etc,but if Multiple items with same name are in the Database, then only the first one gets modified, How to lock the Record which I click by mouse in MSflexGrid1?

    Code:
    Private Sub Msflexgrid1_Click()
    
    
    Dim strq As String
    fnum = FreeFile
     'View an entry from the database
     If MSFlexGrid1.Row > MSFlexGrid1.RowSel Then
            start_row = MSFlexGrid1.RowSel
            stop_row = MSFlexGrid1.Row
        Else
            start_row = MSFlexGrid1.Row
            stop_row = MSFlexGrid1.RowSel
        End If
    
        ' Loop through the selected rows.
        For i = start_row To stop_row
            txt = txt & MSFlexGrid1.TextMatrix(i, 0) & Recnum
        Next i
    
        
        
        With Data1.Recordset
            'MSFlexGrid1.LeftCol = 1
    
            j = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 11)
            'dc = MSFlexGrid1.TextMatrix(MSFlexGrid1.Col, 15)
            dc = Trim(j)
            
            sql1 = "select * from master where DrugName= '" & j & "'"
            'Supp1.Text = j
            
        frmPurch.Show
        aa = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 0)
        bb = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1)
        cc = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2)
        dd = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3)
        ee = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4)
        ff = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5)
        gg = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6)
        hh = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 7)
        ii = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 8)
        jj = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 9)
        kk = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 10)
        ll = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 11)
        mm = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 12)
        nn = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 13)
        oo = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 14)
        Me.Supp1.Text = oo
        Me.drugid.Text = ee
        Me.txtshelf.Text = jj
        Me.Btno.Text = mm
        Me.ltno.Text = cc
        Me.txtcmp.Text = nn
        Me.txtpdate.Text = hh
        Me.txtexpiry.Text = ii
        Me.Purch.Text = gg
        frmPurch.supn.Text = oo
        frmPurch.did.Text = ee
        frmPurch.dnam.Text = ll
        frmPurch.dpdt.Text = aa '!purchdt
        frmPurch.dpcode.Text = bb ' !Pcode
        frmPurch.dplot.Text = cc '!Lotno
        frmPurch.dbat.Text = mm '!BatCHno
        frmPurch.dpack = dd '!Packing
        frmPurch.dqty = kk '!Quantity
        frmPurch.dcost = gg '!CostPrice
        frmPurch.dmfg.Text = hh ' !MfGDate
        frmPurch.dexp.Text = ii '!ExpDate
        frmPurch.dup.Text = ff '!UnitPrice
        frmPurch.dshel.Text = jj ' !Shelf
        frmPurch.dcomp.Text = nn '!Company
        Me.cmbpid.Text = ll
        Me.txtbalance = kk
        Me.supfix.Text = oo
        Me.purchdt.Text = aa
        .Move (MSFlexGrid1.Row - 1) ' we minus one because row zero is the header row
        .Requery
          
        End With
        ' refresh the data source and rebind it to the flexgrid (annoying!!)
        Data1.Refresh
        'Set MSFlexGrid1.DataSource = Data1
    End Sub
    Last edited by dsrahul; November 4th, 2013 at 03:02 AM. Reason: missed something.

  5. #5
    Join Date
    Apr 2006
    Location
    Kolkata, India
    Posts
    278

    Re: Help wanted!!

    Dear Friends,
    Thanks, Its done all by myself,no need to worry.!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center