Hi all,
I borrowed the chunk of code below to perform a similar function on a form I was working with. I understood what the code was doing, but I thought that the Me! was just a placeholder for my own table names. When I used my own table names, however, I got a runtime error 2465. Then, when I used Me! as specified, the code worked perfectly...
I admit my Access skills are a bit rusty, but I don't recall seeing Me! or Me. used before. Can anyone explain how they work or point me to another source that might explain them? It would be much appreciated.
Thanks!
'************* Code Start **************
' This code was originally written by Erika Yoxall.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.'
' Code Courtesy of' Erika Yoxall'
Sub Zip_OnExit(Cancel As Integer)
Dim varState, varCity As Variant
varState = DLookup("State", "tblZipCode", "ZipCode =[Zip] ")
varCity = DLookup("City", "tblZipCode", "ZipCode =[Zip] ")
If (Not IsNull(varState)) Then Me![State] = varState
If (Not IsNull(varCity)) Then Me![City] = varCity
End Sub
************* Code End **************
http://www.mvps.org/access/
I borrowed the chunk of code below to perform a similar function on a form I was working with. I understood what the code was doing, but I thought that the Me! was just a placeholder for my own table names. When I used my own table names, however, I got a runtime error 2465. Then, when I used Me! as specified, the code worked perfectly...
I admit my Access skills are a bit rusty, but I don't recall seeing Me! or Me. used before. Can anyone explain how they work or point me to another source that might explain them? It would be much appreciated.
Thanks!
'************* Code Start **************
' This code was originally written by Erika Yoxall.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.'
' Code Courtesy of' Erika Yoxall'
Sub Zip_OnExit(Cancel As Integer)
Dim varState, varCity As Variant
varState = DLookup("State", "tblZipCode", "ZipCode =[Zip] ")
varCity = DLookup("City", "tblZipCode", "ZipCode =[Zip] ")
If (Not IsNull(varState)) Then Me![State] = varState
If (Not IsNull(varCity)) Then Me![City] = varCity
End Sub
************* Code End **************
http://www.mvps.org/access/
Last edited: