1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
Private Sub txtCodePostal_AfterUpdate()
Dim strCP As String
Dim strSQL As String
Dim oRS As DAO.Recordset
strCP = Nz(Me!txtCodePostal, vbNullString)
If Len(txtCodePostal) = 5 Then
strSQL = "SELECT Ville FROM tblVillesCP WHERE CP ='" & strCP & "';"
Set oRS = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
With oRS
If .EOF Then
MsgBox "Aucune ville ne correspond au code postal " & strCP
Else
Me.lboVilles.RowSource = strSQL
End If
.Close
End With
Else
MsgBox "Veuillez incrire un code postal valide !", vbExclamation
End If
Set oRS = Nothing
End Sub |
Partager