Question : What is wrong with this sql query?

Hi Experts,

I have an sql query inside an access form and i am getting an error (compile error:  type mismatch), it is probably simple, but i can see it.  Can you help?  Thanks :-)


Laura
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
'autopopulates city and state based on data entered into zip code field
    Dim rs As Recordset
    Dim tmpZip As String
    
    If IsNull(txtPhyCity.Value) Then
        
        If Len(txtPhyZip.Value) > 5 Then
            tmpZip = Left(txtPhyZip.Value, 5)
        Else
            tmpZip = txtPhyZip.Value
        End If
       

        Set rs = ("Select * from CityZips Where ZipCode= '" & tmpZip & "'")
        
        If Not rs.EOF Then
            txtPhyCity.Value = rs("City")
            txtPhySt.Value = rs("State")
        End If
    End If
    
    Set rs = Nothing

Answer : What is wrong with this sql query?

change this

Set rs = ("Select * from CityZips Where ZipCode= '" & tmpZip & "'")

to

Set rs = currentdb.openrecordset("Select * from CityZips Where ZipCode= '" & tmpZip & "'")
Random Solutions  
 
programming4us programming4us