954,559 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

creating separator bar in vb6 for the column

jan19.zip



Sir i want to create a separator bar for the column in listbox ,i have written a code . it is working fine .but i need separator bar to distinguish column in a list box :

Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim i As Integer
 Private Sub Form_Load()
 Set con = New Connection
 con.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\asfserver\itp$\Product_tabletest.mdb")
 Set rs = New ADODB.Recordset
 rs.Open "SELECT * From MR ", con, adOpenDynamic, adLockOptimistic
 While (Not (rs.EOF))
 List1.AddItem (rs!req_no & vbNullString & "         " & rs!emp_name & "    " & rs!job_no & "  " & rs!mr_date)
 rs.MoveNext
 Wend
 End Sub
Attachments jan19.zip (81.68KB)
firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

Hi,

You cant have Multiple columns like that.. What you can do is, use a Uniform Width Font and Pad the results with Spaces, and populate the listbox..
Set ListBox's Font = "Courier New"
and Load List Like this :

Dim strReq as String * 10
Dim strName as String * 20
Dim strJob as String * 10
Dim strDate as String * 10
While (Not (rs.EOF))
   strReq = rs!req_no & ""
   strName = rs!emp_name & "" 
   strJob = rs!job_no & "" 
   strDate = rs!mr_date & ""
   List1.AddItem strReq & " " & strName & " " & strJob & " " & strDate
   rs.MoveNext
 Wend


That gives the appearance of Multi Column
If you want to Extract Name or Job Number, you have to use Left / Mid string functions..

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

Madem simple have place a command button crystal report in a mr form then in the click event i have writen Form6.Show vbModeless
and finally form6 i .e under crviewer .i have written a code.

Dim crystal As CRAXDDRT.Application
Dim Report As CRAXDDRT.Report
Dim cparam As CRAXDDRT.ParameterFieldDefinition
Dim cparams As CRAXDDRT.ParameterFieldDefinitions
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset

Private Sub Form_Load()
Call loadreport
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
End Sub

Private Sub Form_Resize()
CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Zoom 100
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth
End Sub
Private Sub loadreport()
    Set con = New Connection
    con.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\asfserver\itp$\Product_tabletest.mdb")
    Set rs = New ADODB.Recordset
    Set crystal = New CRAXDDRT.Application
    Set Report = New CRAXDDRT.Report
    rs.Open "select * from MR", con, adOpenDynamic, adLockOptimistic
    Set Report = crystal.OpenReport(App.Path & "\" & "list2.rpt", 0)
 End Sub
firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

I want if user click on the requisition no 125 or any other req_no
Productname,unit,qty,req_no should come on 2nd list box.Very obliged for your kind assistance
jan19.doc

Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim i As Integer
Dim strReq As String * 10
Dim strName As String * 20
Dim strJob As String * 10
Dim strDate As String * 10
 Private Sub Form_Load()
 Set con = New Connection
 con.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\asfserver\itp$\Product_tabletest.mdb")
 Set rs = New ADODB.Recordset
rs.Open "SELECT * from mr ", con, adOpenDynamic, adLockOptimistic
' List1.AddItem (rs!req_no & vbNullString & "         " & rs!emp_name & "    " & rs!job_no & "  " & rs!mr_date)
 While (Not (rs.EOF))
 strReq = rs!req_no & ""
 strName = rs!emp_name & ""
 strJob = rs!job_no & ""
 strDate = rs!mr_date & ""
 List1.Font = "Courier New"
 List1.AddItem strReq & " " & strName & " " & strJob & " " & strDate
 rs.MoveNext
 Wend
 End Sub
Attachments jan19.doc (155KB)
firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

even better to use any grid control.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

[
jan19.doc



friend req_no,emp_name,job_no,del_date is coming in the first list box . now I want if user click on any column .Mr table another field
Productname
Unit
Qty
Should come on the another list box.
can you help.

Attachments jan19.doc (155KB)
firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

just make an algo on that then use the conditional statements.

jireh
Posting Whiz
316 posts since Jul 2007
Reputation Points: 11
Solved Threads: 49
 

i have tried. here is the code

Dim con As adodb.Connection
Dim rs As adodb.Recordset
Dim i As Integer
Dim strReq As String * 10
Dim strName As String * 20
Dim strJob As String * 10
Dim strDate As String * 10
Dim x As Integer
 Private Sub Form_Load()
  Set con = New Connection
 con.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\asfserver\itp$\Product_tabletest.mdb")
 Set rs = New adodb.Recordset
 rs.Open "SELECT * from mr ", con, adOpenDynamic, adLockOptimistic
' List1.AddItem (rs!req_no & vbNullString & "         " & rs!emp_name & "    " & rs!job_no & "  " & rs!mr_date)
 While (Not (rs.EOF))
 strReq = rs!req_no & ""
 strName = rs!emp_name & ""
 strJob = rs!job_no & ""
 strDate = rs!mr_date & ""
 List1.Font = "Courier New"
 List1.AddItem strReq & " " & strName & " " & strJob & " " & strDate
 rs.MoveNext
 Wend
 End Sub
Private Sub List1_Click()
rs.MoveFirst
<strong>rs.Find "req_no= '" & STRREC & "' "</strong>
If (rs.BOF = True) Or (rs.EOF = True) Then
 MsgBox "Record not found"
Else
 List2.AddItem rs.Fields("productname") & vbNullString
End If
End Sub
firoz.raj
Posting Pro in Training
415 posts since Dec 2008
Reputation Points: 7
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You