?
Solved

Returning to an array number

Posted on 2003-03-04
14
Medium Priority
?
184 Views
Last Modified: 2010-05-01
Dim name As String
name = ""
Dim number As Integer


With adoQuery1
.RecordSource = BuildQuery()
.Refresh
End With

With adoQuery1.Recordset
.MoveFirst
While Not .EOF
name = name & !Player_Name
number = number & !index
.MoveNext
Wend
End With

Above is a query above where i return a name and a number.

I have an array of txtboxes varying from txtPlayer(0) to txtPlayer(12)
So lets say the above query returns Joe Bloggs and 5...i would like the name Joe Bloggs to go into txtPlayer(5).
Any ideas on how to do that??
0
Comment
Question by:reganov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
14 Comments
 
LVL 1

Expert Comment

by:BWarmuskerken
ID: 8064571
txtPlayer(CINT(Number)).text = name
0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8064618
txtPlayer(number).text = name
0
 

Author Comment

by:reganov
ID: 8064690
That will probably workin but i then have the problem of that my query returns Names and numbers as a list like -
Joe BloggsJohnMurphy
1234567
This is my query

SELECT Player_Name,index FROM Query1 WHERE competition_id = 11

So how do i individually put the name into the appropriate textbox
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 8064776
change your code like this:

Dim name() As String
Dim iCount as Integer
Dim number() As Integer


With adoQuery1
.RecordSource = BuildQuery()
.Refresh
End With

With adoQuery1.Recordset
.MoveFirst
While Not .EOF
iCount = iCount + 1
Redim Preserve Name(iCount)
Redim Preserve number(iCount)
name(icount) =  !Player_Name
number(iCount) = !index
.MoveNext
Wend
End With

now you can use the Array indexes to pass the corresponding Array members to the TextBoxes.

AW
0
 
LVL 1

Expert Comment

by:BWarmuskerken
ID: 8064825
All you really need to do is this, no need to set up the string arrays.

With adoQuery1.Recordset
.MoveFirst
While Not .EOF
iCount = iCount + 1
Redim Preserve Name(iCount)
Redim Preserve number(iCount)
number = !index
txtName(cint(number).text =  !Player_Name
.MoveNext
Wend
End With
0
 

Author Comment

by:reganov
ID: 8065031
That will probably workin but i then have the problem of that my query returns Names and numbers as a list like -
Joe BloggsJohnMurphy
1234567
This is my query

SELECT Player_Name,index FROM Query1 WHERE competition_id = 11

So how do i individually put the name into the appropriate textbox
0
 

Author Comment

by:reganov
ID: 8065073
That will probably workin but i then have the problem of that my query returns Names and numbers as a list like -
Joe BloggsJohnMurphy
1234567
This is my query

SELECT Player_Name,index FROM Query1 WHERE competition_id = 11

So how do i individually put the name into the appropriate textbox
0
 

Author Comment

by:reganov
ID: 8065174
Im dont quiet understand this. I have the code above at the top in the form_load(). How do i adjust this for my index.
0
 
LVL 1

Accepted Solution

by:
BWarmuskerken earned 80 total points
ID: 8065234
Dim name As String
name = ""
Dim number As Integer


With adoQuery1
.RecordSource = BuildQuery()
.Refresh
End With

With adoQuery1.Recordset
.MoveFirst
While Not .EOF
  number = !index
  txtName(cint(number))= !Player_Name
  .movenext
Wend
End With
0
 

Author Comment

by:reganov
ID: 8065258
Im dont quiet understand this. I have the code above at the top in the form_load(). How do i adjust this for my index.
0
 

Author Comment

by:reganov
ID: 8065323
txtName(cint(number))= !Player_Name
this is the part that is causing a problem i get "sub or function not defined" error!
0
 
LVL 1

Expert Comment

by:BWarmuskerken
ID: 8065369
Are you using VB6? If not...

change it to:

 txtName(number).text

0
 

Author Comment

by:reganov
ID: 8065382
Sorry, got it. its txtPlayer rather than txtName.
Having a problem with the sql statment now though
0
 

Author Comment

by:reganov
ID: 8065403
Got it working! Cheers for the help BWarmuskerken!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question