dynamic array help

M

Marc

i need to change the below array so that it is dynmanic...how can i do
this?

i.e there wont always be 4 values.

Sub MapSelectedProperties()
Dim objLoc2(1 To 4) As MapPoint.Location
Dim i As Integer
i = 0
Set Recordset = CurrentDb.OpenRecordset("SELECT * FROM
tblProperties;")
If Recordset.RecordCount > 0 Then
While Not Recordset.EOF
i = i + 1
Set objLoc2(i) = objMap.FindAddressResults(Recordset!strStreet,
Recordset!strCity, Recordset!strState, Recordset!strPostalCode)(1)
Set objPin = objMap.AddPushpin(objLoc2(i), Recordset!strStreet)
Recordset.MoveNext
Wend
End If
objMap.Shapes.AddPolyline objLoc2


End Sub
 
A

Allen Browne

You an ReDim an array at runtime:

Dim lngHowMany As Long
lngHowMany = Nz(DCount("*", "tblProperties"), 0)
ReDim objLoc2(lngHowMany) As ...
 
M

Marc

Thanks it works now!!!

Allen said:
You an ReDim an array at runtime:

Dim lngHowMany As Long
lngHowMany = Nz(DCount("*", "tblProperties"), 0)
ReDim objLoc2(lngHowMany) As ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top