Control becomes read-only

A

Alex

I have a routine (GetCityStateFromZip) that performs a query into a zip-code
table and returns a city and a state from a zip argument. Calling this routine
from the LostFocus event of a control is causing the control to become
read-only. Does anybody have any ideas as to why this is happening?

Private Sub TextBoxOZip_LostFocus()

Dim TheCity As String
Dim TheState As String

GetCityStateFromZip TextBoxOZip.Value, TheCity, TheState
TextBoxCity.Value = TheCity
TextBoxZipState.Value = TheState

End Sub

Sub GetCityStateFromZip(ByVal AZip As String, ByRef ACity As String, ByRef
AState As String)

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset

Set db = CurrentDb
Set qdf = db.QueryDefs("Q_ZipLatLongForZipCode")
qdf.Parameters("pZipCode") = AZip
Set rs = qdf.OpenRecordset
ACity = rs.Fields("CITY")
AState = rs.Fields("STATE")
rs.Close
Set rs = Nothing
Set qdf = Nothing
Set db = Nothing

End Sub
 

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