Hello,
I'm getting Error 91, (Object Variable or With Block not set) with the following code:
Sub MapSelectedProperties()
'Map the selected properties
On Error GoTo MapSelectedProperties_Err_Exit
Dim db As Database
Dim rstProps As DAO.Recordset
Dim objLoc As MapPoint.Location
Dim objMap As MapPoint.map
Dim objPushpin As MapPoint.Pushpin
Dim strMsg As String
Dim i As Integer
i = 0
Set db = CurrentDb()
'Load the selected properties into a recordset
Set rstProps = CurrentDb.OpenRecordset("Get20Mile_SelQry")
'Make sure at least one property was selected
If rstProps.RecordCount > 0 Then
'Load Map
If LoadMap() Then
'Open the form containing the map
FormOpen "frmMap"
Set objMap = gappMP.ActiveMap
'Place a pushpin on the map for each selected property
While Not rstProps.EOF
i = i + 1
Set objLoc = objMap.FindAddressResults(rstProps!Address_1, rstProps!City, rstProps!State, rstProps!Zip)(1)
Set objPushpin = objMap.AddPushpin(objLoc, rstProps!Address_1)
objPushpin.Name = CStr(i)
objPushpin.Note = rstProps!Company
objPushpin.BalloonState = geoDisplayBalloon
objPushpin.Symbol = 77
objPushpin.Highlight = True
rstProps.MoveNext
Wend
'Show all pushpins on the map display
objMap.DataSets.ZoomTo
Else
strMsg = "Unable to load map."
MsgBox strMsg, vbOKOnly + vbExclamation, APP_NAME
End If
Else
strMsg = "No properties selected."
MsgBox strMsg, vbOKOnly + vbExclamation, APP_NAME
End If
MapSelectedProperties_Err_Exit:
On Error Resume Next
Set objPushpin = Nothing
Set objLoc = Nothing
Set objMap = Nothing
rstProps.Close
db.Close
Exit Sub
MapSelectedProperties_Err:
Resume MapSelectedProperties_Err_Exit
End Sub
I'm trying to run a query, but continue to receive this error at the following line:
rstProps.Close
Thanks for your help in advance!
I'm getting Error 91, (Object Variable or With Block not set) with the following code:
Sub MapSelectedProperties()
'Map the selected properties
On Error GoTo MapSelectedProperties_Err_Exit
Dim db As Database
Dim rstProps As DAO.Recordset
Dim objLoc As MapPoint.Location
Dim objMap As MapPoint.map
Dim objPushpin As MapPoint.Pushpin
Dim strMsg As String
Dim i As Integer
i = 0
Set db = CurrentDb()
'Load the selected properties into a recordset
Set rstProps = CurrentDb.OpenRecordset("Get20Mile_SelQry")
'Make sure at least one property was selected
If rstProps.RecordCount > 0 Then
'Load Map
If LoadMap() Then
'Open the form containing the map
FormOpen "frmMap"
Set objMap = gappMP.ActiveMap
'Place a pushpin on the map for each selected property
While Not rstProps.EOF
i = i + 1
Set objLoc = objMap.FindAddressResults(rstProps!Address_1, rstProps!City, rstProps!State, rstProps!Zip)(1)
Set objPushpin = objMap.AddPushpin(objLoc, rstProps!Address_1)
objPushpin.Name = CStr(i)
objPushpin.Note = rstProps!Company
objPushpin.BalloonState = geoDisplayBalloon
objPushpin.Symbol = 77
objPushpin.Highlight = True
rstProps.MoveNext
Wend
'Show all pushpins on the map display
objMap.DataSets.ZoomTo
Else
strMsg = "Unable to load map."
MsgBox strMsg, vbOKOnly + vbExclamation, APP_NAME
End If
Else
strMsg = "No properties selected."
MsgBox strMsg, vbOKOnly + vbExclamation, APP_NAME
End If
MapSelectedProperties_Err_Exit:
On Error Resume Next
Set objPushpin = Nothing
Set objLoc = Nothing
Set objMap = Nothing
rstProps.Close
db.Close
Exit Sub
MapSelectedProperties_Err:
Resume MapSelectedProperties_Err_Exit
End Sub
I'm trying to run a query, but continue to receive this error at the following line:
rstProps.Close
Thanks for your help in advance!