Link to home
Start Free TrialLog in
Avatar of reganov
reganov

asked on

Returning to an array number

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??
Avatar of BWarmuskerken
BWarmuskerken

txtPlayer(CINT(Number)).text = name
txtPlayer(number).text = name
Avatar of reganov

ASKER

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
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
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
Avatar of reganov

ASKER

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
Avatar of reganov

ASKER

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
Avatar of reganov

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of BWarmuskerken
BWarmuskerken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of reganov

ASKER

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.
Avatar of reganov

ASKER

txtName(cint(number))= !Player_Name
this is the part that is causing a problem i get "sub or function not defined" error!
Are you using VB6? If not...

change it to:

 txtName(number).text

Avatar of reganov

ASKER

Sorry, got it. its txtPlayer rather than txtName.
Having a problem with the sql statment now though
Avatar of reganov

ASKER

Got it working! Cheers for the help BWarmuskerken!