473,385 Members | 1,817 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,385 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 11243
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.