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

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

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

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

even better to use any grid control.

[
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.

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
[B]rs.Find "req_no= '" & STRREC & "' "[/B]
If (rs.BOF = True) Or (rs.EOF = True) Then
 MsgBox "Record not found"
Else
 List2.AddItem rs.Fields("productname") & vbNullString
End If
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.