473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dlookup to populate a form

I am trying to use Dlookup to populate a text box on a form, but
haven't had any good luck so far. I've looked here at the posts
and have used the Access help for examples. Northwind is way over my
head. I think that I'm coming up short in the Criteria part of the
function.

I have a combo box that looks to the 'Student' table,
'Student_ID' field to list the students, and then places the
selected value in the 'Student_ID' text box on the 'Order'
form. The combo box part works well. The text boxes on the
'Order' form are bound to an 'OrderEntry' table.

What I am trying to do is to fill in the 'LastName' text box in the
'Order' form using the data from the 'Student' table,
'LastName' field. I think that the criteria for the lookup would
be the value in the 'Student_ID' combo box on the form, using an
event procedure triggered by the AfterUpdate event.

What I would like is to have an example of the Dlookup function as it
applies to my application.

Many thanks for your time and any help given.

David

Dec 3 '06 #1
3 11245
Try this for size. Base you "Order" form on a query that joins the
"OrderEntry" table to the "Student" table by the "Student_ID" field and
include the "LastName" field in the returned fields. The bind your
txtLastName control to the LastName field and when you select the student
with the ComboBox, the txtLastName control will just magically complete
itself.

David wrote:
>I am trying to use Dlookup to populate a text box on a form, but
haven't had any good luck so far. I've looked here at the posts
and have used the Access help for examples. Northwind is way over my
head. I think that I'm coming up short in the Criteria part of the
function.

I have a combo box that looks to the 'Student' table,
'Student_ID' field to list the students, and then places the
selected value in the 'Student_ID' text box on the 'Order'
form. The combo box part works well. The text boxes on the
'Order' form are bound to an 'OrderEntry' table.

What I am trying to do is to fill in the 'LastName' text box in the
'Order' form using the data from the 'Student' table,
'LastName' field. I think that the criteria for the lookup would
be the value in the 'Student_ID' combo box on the form, using an
event procedure triggered by the AfterUpdate event.

What I would like is to have an example of the Dlookup function as it
applies to my application.

Many thanks for your time and any help given.

David
--
HTH - RuralGuy (RG for short) acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 4 '06 #2
Hi David,

Assuming the table “Student” has a column named “LastName” and in your
“Student_ID” ComboBox, your rowsource should look like,

“SELECT [Student_ID], LastName FROM Student”

Make sure the combo Format tab properties – ColumnCount = 2.

Since combo “Student_ID” and TextBox “ LastName” were bound to the OrderEntry
table.

In the AfterUpdate event of your ComboBox, try this

Me.LastName = DlookUp(“LastName”, Student”, “[Studen_ID] = ” & Me.Student_ID)

'if Student_ID datatype is text, use the quotes like .. Student_ID = '" & me.
Student_ID & "'")

Or

Me.LastName = Me.Student_ID.Column(1)

‘.Column(0) is the Query grid Field “Student_ID”
‘.Column(1) is the Query grid Field “LastName”
‘To use this, you need to set the “Student_ID combobox ColumnCount = 2 in the
combobox properties.
>David wrote:
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200612/1

Dec 4 '06 #3
Try

DLookUp("LastName","Student","Student_ID = " & Me.[Name of your combo
box])

This should work if your Student_ID is a number field

If it's a text field try

DLookUp("LastName","Student","Student_ID = ' " & Me.[Name of your combo
box] & " ' ")

Geoff

Dec 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Hargrove | last post by:
I am building a database to manage test samples in an environmental laboratory. I am learning Access as I go and don't know much about the programming aspects. I hope to make the application...
6
by: JLM | last post by:
What am I missing here? I have a form where I enter a "Class Code". This value corresponds to what sits in table "class code descriptions" along with the "title" of each "class code." Key...
1
by: Knud Rogilds | last post by:
I have tried everything, what am I doing wrong? I have a data entry form in datasheet view (for mass data entry). One of the fields are SalesID, and I would like to use DLookup to populate an...
6
by: Don Sealer | last post by:
I've written this expression for a DLookup function. It works almost alright. What I'm trying to do is type in a description and the ID field (number) populates automatically. It works almost as...
1
by: Parasyke | last post by:
I have a form (I won't bore you with the details of the necessity of this, but), I need to have a textbox that uses DLookup to get a value from a table with both being keyed to a common field...
1
by: dmeyr | last post by:
Hello, I am new to Access and am having difficulty with a Dlookup function. I have a form that I wish to autopopulate 10 fields with values based on two criteria which are also fields on the form....
2
by: boyleyc | last post by:
Hi all the following code works perfectly well. Basically it populates a series of check boxes on my form, depending on whether dlookup finds an associated record. The problem i have is that...
1
by: aharding | last post by:
Hello! I am using Access 2003 I have been playing with DLookup all morning and have not been successful yet. I have never used this function...and have some limited experience with code. I...
2
by: CrazyAL | last post by:
I am working on a form to add entries into my assets table. I am trying to figure out how to make a purchase price field auto populate after entering model number into a combo box. There maybe a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.