PC Review


Reply
Thread Tools Rate Thread

DLookup code for auto-populating a control on a form

 
 
pedro
Guest
Posts: n/a
 
      30th Jul 2008
I am trying to auto-fill a combo-box on a form based on the selection from
another combo-box.

It is triggered on an after update event on the first combo-box selection.
The code I have is;

If not IsNull([Vehicle Model]) Then
Dim org as Variant
Dim pName As String
pName = [Vehicle Model].value

org = DLookup("shape","tbl_vehmodel","model = ' " & pName & "'")

End If

Shape is a field in the table tbl_vehmodel that I want to lookup based on
the name of the vehicle model selected in the combo-box. The combo-box I want
to auto-fill is called Vehicle Shape.

The syntax runs without errors however the Vehicle Shape field is not
populated.

Your suggestions would be greatly appreciated.
 
Reply With Quote
 
 
 
 
Dennis
Guest
Posts: n/a
 
      30th Jul 2008
Don't know if it is just a typing error but you have a space after the first
apostrophe.
The line should be
org = DLookup("shape","tbl_vehmodel","model = '" & pName & "'")

Also DLookup will only return 1 value, so why are using a combo box to
display 1 value ?

"pedro" wrote:

> I am trying to auto-fill a combo-box on a form based on the selection from
> another combo-box.
>
> It is triggered on an after update event on the first combo-box selection.
> The code I have is;
>
> If not IsNull([Vehicle Model]) Then
> Dim org as Variant
> Dim pName As String
> pName = [Vehicle Model].value
>
> org = DLookup("shape","tbl_vehmodel","model = ' " & pName & "'")
>
> End If
>
> Shape is a field in the table tbl_vehmodel that I want to lookup based on
> the name of the vehicle model selected in the combo-box. The combo-box I want
> to auto-fill is called Vehicle Shape.
>
> The syntax runs without errors however the Vehicle Shape field is not
> populated.
>
> Your suggestions would be greatly appreciated.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Populating city, state and county based on the zip code. matrix7410@yahoo.com Microsoft Access Reports 1 24th Mar 2009 02:51 AM
Trouble auto populating field using DLookUp bcp1961 via AccessMonster.com Microsoft Access Form Coding 3 6th Feb 2008 08:44 PM
Auto populating City and St. based on zip code X Microsoft Access Forms 2 3rd Aug 2004 05:19 AM
Auto populating form Jason Microsoft Access Form Coding 1 1st Apr 2004 06:39 PM
auto populating a form Sean Microsoft Access Forms 1 28th Jan 2004 08:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:42 PM.