how to display all values in excel sheet

Hello,

im trying to retreive some data based on a value, for eg: im having a_nr as 1500.001

this particular a_nr has some version numbers, ie 1500.001 ver1
                                                                                      ver1
                                                                                      ver2
etc, so with my code im able to display one one ver using range, but what i want to do is display all the versions numbers that belong to 1500.001

can somebody tell me how to go about

thanks

-----------------

Dim clk As String

clk = ComboBox1.List(ComboBox1.ListIndex) + "." + ComboBox2.List(ComboBox2.ListIndex)

'MsgBox clk

Dim conn As ADODB.Connection
Dim rec As ADODB.Recordset


Set conn = New ADODB.Connection

conn.Open "Driver={Microsoft ODBC for Oracle};" & _
                   "Server=;" & _
                   "Uid=;" & _
                   "Pwd=;"

   Set rec = New ADODB.Recordset

rec.Open "SELECT * FROM project_data3 where ang_kost1='" & clk & "'", conn

While Not rec.EOF
   
   Tabelle2.Range("A23") = (rec.Fields("ver_nr1").Value)
   Tabelle2.Range("B23") = (rec.Fields("ver_bes1").Value)
   rec.MoveNext
   Wend

rec.Close
Set rec = Nothing
vihar123Asked:
Who is Participating?
 
gbzhhuConnect With a Mentor Commented:
OK here

Dim i As Integer

i = 22

While Not rec.EOF  
   i = i + 1
   Tabelle2.Cells(i,1) = (rec.Fields("ver_nr1").Value)
   rec.MoveNext
Wend
0
 
gbzhhuCommented:
The question is not clear.

What is a_nr ?  Could please elaporate further.  try to explain a bit more
0
 
vihar123Author Commented:
its something like order number, and this order number has some versions, so when the user selects this particular order number i want to display all the version numbers belonging to this order nr and mostly the version number are repeated , that is ver1 comes for many n number of times,

so basically im trying to diplay all the versions that belong to order number

0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
gbzhhuCommented:
So, the recordset is returning the version numbers, correct and you want to display in excel cells all the versions of the select order number?  Just clarifying.  What are the field names of the version numbers in the database?  Is there a fixed number of versions per order or is this dynamic
0
 
vihar123Author Commented:
not its dynamic and i have made a view of tables and im retreiving data from this view, so the table and values looks something like this, so when the user selects 1500.001, all the ver_nr should be displayed


ANG_KOST1 VER_NR1
1500.001       1
1500.001       1
1500.001       1
1500.001       1
1500.001       1
1500.001       1
0
 
gbzhhuCommented:
Now I see.  Try this

Dim i As Integer

While Not rec.EOF  
   i = i + 1
   Tabelle2.Cells(23, i) = (rec.Fields("ver_nr1").Value)
   rec.MoveNext
Wend

0
 
vihar123Author Commented:
cool but i want them in a column something like A starting from 23 row
0
 
vihar123Author Commented:
is it possible, im trying with range and other thins but its nor working
0
 
vihar123Author Commented:
i want to display data in column A starting from 23 row
0
 
gbzhhuCommented:
Just change this
   Tabelle2.Cells(i,1) = (rec.Fields("ver_nr1").Value)
to
   Tabelle2.Cells(23,i) = (rec.Fields("ver_nr1").Value)

and remove
i = 22
0
 
vihar123Author Commented:
ok its working thanks..................

0
 
vihar123Author Commented:
one more thing, though i will open it as a new thread

i need to get some info in between these versions, something like now the output is

1
1
1
1
1
1
1
so i want to bring in some data from db and place them in the beween something like

1
station number 21       description
1
station number 21       description

etc........................

do i need to change my code or just some query
0
 
gbzhhuCommented:
You will need to change code, just post the code (only the bit we discussed --in the while loop) and I will change it for you

You said your display looks like 1
1
1
1
1
1
1

But I thought it will be like

1   1   1   1   1  1  

filling columns in on row 23
0
 
vihar123Author Commented:
sorry there was a slight misunderstanding, then let me post this as  a  new thread
0
 
gbzhhuCommented:
OK
0
 
vihar123Author Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.