Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Using DLookUp to populate a form field

Thurls (MIS) (OP)
15 Jun 03 23:44
Hello all,

I'm new to this site so be kind, I use a form to poulate a table in Access 2000, in the form there is a field to input suburb then another to enter the post code for that suburb. I have a another table with all the suburbs and their post codes so I thought I could use DLookUp to populate the post code field.

I'm using a VB code on enter, like this

Private Sub Postcode_Enter()
Dim varX As Variant
varX = DLookup("[Pcode]", "T_Postcodes", "[Suburb1] = '" & Me![Suburb] & "'")
End Sub

but get a nothing in the postcode field, not getting an error message just no result. any ideas?

Cheers,

Cole
scriverb (Programmer)
16 Jun 03 0:02
Your idea is a good one.  You are just not executing this code at all.  Put the following code in the forms OnCurrent event procedure and the AfterUpdate event procedure of the [Suburb] control.

Me![Post_Code] = DLookup("[Pcode]", "T_Postcodes", "[Suburb1] = '" & Me![Suburb] & "'")

This way everytime you move to a new record or someone updates the [suburb] control the DLookup will populate the control Me![Post_Code].  Change this control to the name of your forms control.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

Thurls (MIS) (OP)
16 Jun 03 1:36
Thanks for your help, much appreciated, It works great.
I have lots to learn.

Cheers,

Cole
scriverb (Programmer)
16 Jun 03 7:21
Great!!

Glad to be of help.  As for having a lot to learn, we have all been there.  One step at a time and pretty soon you will be answering questions here.

Bob Scriver

Nobody believes the official spokesman... but everybody trusts an unidentified source.
Author, Bagdad Bob???

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close