Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading data into array

Status
Not open for further replies.

99Chuck99

Programmer
Dec 11, 2003
67
US
I have a simple issue but can not figure it out to save my life. I have posted a section of code out of my function. I can not not seem to load the array with the string data rather then the data name. Any help would be appreciated. Thanks

ElseIf ctlcount = 2 Then

data1 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID1) = " & "'" & item2 & "'"
data2 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID2) = " & "'" & item2 & "'"
data3 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID3) = " & "'" & item2 & "'"
data4 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID4) = " & "'" & item2 & "'"
data5 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID5) = " & "'" & item2 & "'"
data6 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID6) = " & "'" & item2 & "'"
data7 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID7) = " & "'" & item2 & "'"
data8 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID8) = " & "'" & item2 & "'"
data9 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID9) = " & "'" & item2 & "'"
data10 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID10) = " & "'" & item2 & "'"
data11 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID11) = " & "'" & item2 & "'"
data12 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID12) = " & "'" & item2 & "'"
data13 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID13) = " & "'" & item2 & "'"
data14 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID14) = " & "'" & item2 & "'"
data15 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID15) = " & "'" & item2 & "'"
data16 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID16) = " & "'" & item2 & "'"
data17 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID17) = " & "'" & item2 & "'"
data18 = " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID18) = " & "'" & item2 & "'"


End If

For intX = 1 To 18

returndata(intX) = "data" & [intX]
MsgBox "data" & [intX] (THIS IS WHERE MY PROBLEM IS)
Next intX
 
This will not even compile.

"data" & [intX]

your trying to concatenate a string "data" to some undefined notation []. Even if you did this
"data" & intX
it will resolve to a string
"data1", not to a variable.

The closest you could do something like this is using the eval function, but that does not do it.
What is wrong with?
returndata(1)= " LIKE '" & item1 & "'" & " Or ([OMEU-MEE].ID1) = " & "'" & item2 & "'
 
Actually it does compile if you leave the []. Still the same problem, this resolve to a string not to a variable.
 
as MajP said, can't concatenate a variable.
...the value yes, not the variable itself.

a slight modification of MajP's suggestion,

For intX = 1 To 18

returndata(intX) = _
" LIKE '" & item1 & "' Or ([OMEU-MEE].ID" & intx & ") = '" & item2 & "'"
Next intX

NO NEED to declare all your variables...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top