Steve E. has a very good suggestion that you may want to consider. The
procedure would be the same, just the name of the table would be different.
[color=blue]
> State = DLookup("State", "Table2", "ZipCode = '"&ZipCode"'")[/color]
For starters, you are typing this into the event procedure in the VBA
window, not directly into the Properties sheet, correct? Next, the syntax at
the end is off a little. You need to concatenate the zip code and the quotes
together so that the zip code gets passes as a text value (zip codes are
normally text, if you have them as number, you would need to change this).
State = DLookup("State", "Table2", "ZipCode = '" & ZipCode & "'")
Also, it appears that your textboxes have the same name as the fields they
are bound to. This may not cause you a problem here, but is can cause a
problem in some cases. I would recommend renaming them. Every object in your
database should have a unique name. The easiest way to rename them yet keep
them meaningful is to put a prefix on the name, such as txt for a textbox.
That would change the name of the State textbox to txtState. For a listing
of commonly used prefixes, check this link.
http://www.mvps.org/access/general/gen0012.htm
--
Wayne Morgan
Microsoft Access MVP
"AS Mann" <tansenva@aol.com> wrote in message
news:40969f80$0$201$75868355@news.frii.net...[color=blue]
>
> Thanks Wayne for the response. I tried typing the command into the
> after update event but kept getting errors. Am I missing something
> here?
>
> I typed the following into the afterupdate event of the Zip Code
> Textbox:
>
> State = DLookup("State", "Table2", "ZipCode = '"&ZipCode"'")
>
> Am I doing something wrong with the spaces? The name of the ZipCode
> field in both tables is "ZipCode" and the name of the State field in
> both tables is "State".
>
> I hope I can get this!
>
>
> *** Sent via Developersdex
http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]