473,383 Members | 1,918 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,383 software developers and data experts.

DLookup() problems Please Help!

I am fairly new to Access, and am trying to put together an invoice
form. The main form in called InvoiceDetailFm. Source is the table
InvoiceDetail and has invoice number, saleman, and CustID as some of
its fields. I have put together a combobox, named it CustID, and am
trying to use DLookup() to bring the complete Customer Name etc onto
the form using DLookup() function for the fields I need. The combobox
will bring up the CustID in the Customer table and DLookup brings up
the fields I want just fine. HOWEVER, if the user decides that the
CustID was the wrong one, a second try on the Combobox will produce
another CustID, but will NOT change any of the previous DLookup()
fields. So they way it is now, If the user made a mistake and put the
wrong CustID in the first time, and he changes it, the DLookup() will
not change.

What am I doing wrong, and how can I correct this?
/kal
Nov 12 '05 #1
5 3171
On 5 Apr 2004 08:39:15 -0700, vi***********@hotmail.com (Kalvin
Schroder) wrote:
I am fairly new to Access, and am trying to put together an invoice
form. The main form in called InvoiceDetailFm. Source is the table
InvoiceDetail and has invoice number, saleman, and CustID as some of
its fields. I have put together a combobox, named it CustID, and am
trying to use DLookup() to bring the complete Customer Name etc onto
the form using DLookup() function for the fields I need. The combobox
will bring up the CustID in the Customer table and DLookup brings up
the fields I want just fine. HOWEVER, if the user decides that the
CustID was the wrong one, a second try on the Combobox will produce
another CustID, but will NOT change any of the previous DLookup()
fields. So they way it is now, If the user made a mistake and put the
wrong CustID in the first time, and he changes it, the DLookup() will
not change.

What am I doing wrong, and how can I correct this?
/kal


In the After Update event for CustID:

If isnull(me.CustID)=false then
'execute all the Dlookups to retrieve data related to CustID
end if

Chuck
Nov 12 '05 #2
On Mon, 05 Apr 2004 16:53:56 -0400, Chuck Van Den Corput
<NO*****************@sympatico.ca> wrote:
On 5 Apr 2004 08:39:15 -0700, vi***********@hotmail.com (Kalvin
Schroder) wrote:
I am fairly new to Access, and am trying to put together an invoice
form. The main form in called InvoiceDetailFm. Source is the table
InvoiceDetail and has invoice number, saleman, and CustID as some of
its fields. I have put together a combobox, named it CustID, and am
trying to use DLookup() to bring the complete Customer Name etc onto
the form using DLookup() function for the fields I need. The combobox
will bring up the CustID in the Customer table and DLookup brings up
the fields I want just fine. HOWEVER, if the user decides that the
CustID was the wrong one, a second try on the Combobox will produce
another CustID, but will NOT change any of the previous DLookup()
fields. So they way it is now, If the user made a mistake and put the
wrong CustID in the first time, and he changes it, the DLookup() will
not change.

What am I doing wrong, and how can I correct this?
/kal


In the After Update event for CustID:

If isnull(me.CustID)=false then
'execute all the Dlookups to retrieve data related to CustID
end if

Chuck


I should have mentioned that the Dlookups should go in code rather
than the Control Source for the customer-related fields (if, in fact,
that's what you are doing).

Chuck
Nov 12 '05 #3
Chuck

Do you need to use dlookup()? I find them really slow. You should have
a table tblCustomers with contactTitle, contactFirst, contactLast etc.
If you don't maybe you should consider it. If you do make a new combo
set the combo's rowsource to(something like):

SELECT DISTINCTROW customerID, CustomerFirst & " " & CustomerLast as
Customer, CustomerLast FROM tblCustomers ORDER BY CustomerLast

set the bound column to 2 & you'll display the customer's name just
nicely. It'll load much faster than a dlookup() & there's no code to
mess around with

Neil

Chuck Van Den Corput <NO*****************@sympatico.ca> wrote in message news:<n6********************************@4ax.com>. ..
On Mon, 05 Apr 2004 16:53:56 -0400, Chuck Van Den Corput
<NO*****************@sympatico.ca> wrote:
On 5 Apr 2004 08:39:15 -0700, vi***********@hotmail.com (Kalvin
Schroder) wrote:
I am fairly new to Access, and am trying to put together an invoice
form. The main form in called InvoiceDetailFm. Source is the table
InvoiceDetail and has invoice number, saleman, and CustID as some of
its fields. I have put together a combobox, named it CustID, and am
trying to use DLookup() to bring the complete Customer Name etc onto
the form using DLookup() function for the fields I need. The combobox
will bring up the CustID in the Customer table and DLookup brings up
the fields I want just fine. HOWEVER, if the user decides that the
CustID was the wrong one, a second try on the Combobox will produce
another CustID, but will NOT change any of the previous DLookup()
fields. So they way it is now, If the user made a mistake and put the
wrong CustID in the first time, and he changes it, the DLookup() will
not change.

What am I doing wrong, and how can I correct this?
/kal


In the After Update event for CustID:

If isnull(me.CustID)=false then
'execute all the Dlookups to retrieve data related to CustID
end if

Chuck


I should have mentioned that the Dlookups should go in code rather
than the Control Source for the customer-related fields (if, in fact,
that's what you are doing).

Chuck

Nov 12 '05 #4
On 6 Apr 2004 07:39:17 -0700, ne***********@boroughmuir.edin.sch.uk
(NeilAnderson) wrote:
Chuck

Do you need to use dlookup()? I find them really slow. You should have
a table tblCustomers with contactTitle, contactFirst, contactLast etc.
If you don't maybe you should consider it. If you do make a new combo
set the combo's rowsource to(something like):

SELECT DISTINCTROW customerID, CustomerFirst & " " & CustomerLast as
Customer, CustomerLast FROM tblCustomers ORDER BY CustomerLast

set the bound column to 2 & you'll display the customer's name just
nicely. It'll load much faster than a dlookup() & there's no code to
mess around with

Neil


Neil,

I agree that your solution is preferable ro mine and the one I would
go with myself. I just wasn't sure how to explain it to someone new to
Access. Maybe I'll give it a whirl here.

Let's say that Kal wants read-only controls on his form displaying the
address, city and phone number corresponding to the customer the user
has selected.

His CustID combo box control could be driven by a querydef with these
columns: CustID, CustName, CustAddress, CustCity, CustPhoneNumber,
sorted by CustName.

While the combo box could show all these pieces of information in the
dropdown list, let's say he only wanted to see CustName. Then he would
set the Column Count to 5 and the Column Widths to 0;2;0;0;0 so that
the only column the user would see would be the second one. His Bound
Column would be 1.

Then, in his read-only controls (Enabled=No, Locked=Yes) he could set
the Control Source as:
txtAddress: =CustID.column(2)
txtCity: =CustID.column(3)
txtPhone: =CustID.column(4)

Note that the column numbers are offsets, thus the first column is 0.

The controls txtAddress, txtCity and txtPhone would always self-adjust
based on the value of CustID.

Chuck
Nov 12 '05 #5
Chuck

Yes, that looks fine. I've never really needed to do this sort of
thing myself. I must admit that I'd only put the customer's name on an
invoice form, if I needed their details I'd use a sub form. But maybe
he really needs them?

Neil

Chuck Van Den Corput <NO*****************@sympatico.ca> wrote in message news:<bd********************************@4ax.com>. ..
On 6 Apr 2004 07:39:17 -0700, ne***********@boroughmuir.edin.sch.uk
(NeilAnderson) wrote:
Chuck

Do you need to use dlookup()? I find them really slow. You should have
a table tblCustomers with contactTitle, contactFirst, contactLast etc.
If you don't maybe you should consider it. If you do make a new combo
set the combo's rowsource to(something like):

SELECT DISTINCTROW customerID, CustomerFirst & " " & CustomerLast as
Customer, CustomerLast FROM tblCustomers ORDER BY CustomerLast

set the bound column to 2 & you'll display the customer's name just
nicely. It'll load much faster than a dlookup() & there's no code to
mess around with

Neil


Neil,

I agree that your solution is preferable ro mine and the one I would
go with myself. I just wasn't sure how to explain it to someone new to
Access. Maybe I'll give it a whirl here.

Let's say that Kal wants read-only controls on his form displaying the
address, city and phone number corresponding to the customer the user
has selected.

His CustID combo box control could be driven by a querydef with these
columns: CustID, CustName, CustAddress, CustCity, CustPhoneNumber,
sorted by CustName.

While the combo box could show all these pieces of information in the
dropdown list, let's say he only wanted to see CustName. Then he would
set the Column Count to 5 and the Column Widths to 0;2;0;0;0 so that
the only column the user would see would be the second one. His Bound
Column would be 1.

Then, in his read-only controls (Enabled=No, Locked=Yes) he could set
the Control Source as:
txtAddress: =CustID.column(2)
txtCity: =CustID.column(3)
txtPhone: =CustID.column(4)

Note that the column numbers are offsets, thus the first column is 0.

The controls txtAddress, txtCity and txtPhone would always self-adjust
based on the value of CustID.

Chuck

Nov 12 '05 #6

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

Similar topics

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...
5
by: Kalvin Schroder | last post by:
I am fairly new to Access, and am trying to put together an invoice form. The main form in called InvoiceDetailFm. Source is the table InvoiceDetail and has invoice number, saleman, and CustID as...
1
by: Edward S | last post by:
Friends, I had posted this on "Microsoft.Public.Access", But I did not get a satisfactory response. I have been struggling for nearly 2 days trying to crack this code. I really need help, could...
6
by: LSemos | last post by:
I am trying to lookup phone numbers in a separate table based on the name in the current Tab control tblContacts has the fields: Name, Phone, Fax, and Email In my Form's Tab control, I have...
0
by: Tony Williams | last post by:
I have posted a number of posts in the Access newsgroups concerning my problem with DLookup. I have had a number of the experts with helpful suggestions but I still can't get it to work! This is...
1
by: Tony Ciconte | last post by:
I am using Acc97 and trying to get the following instruction to work in the OnOpen event of a report: DLookup("", "tblTempRevenueByFY", DatePart("m", ) = 1) The table tblTempRevenueByFY...
2
by: Don | last post by:
Can someone help me fix my DLookup problem. I'm far from proficiency with Access. I've been creating databases for several years for work with the help of many of you and trial and error. I have...
2
by: sfrvn | last post by:
I am embarrassed to say I cannot make this work. Recently upgraded to Access 2003, but do not know if that part of problem (AKA 'syntax change'). Would someone be kind enough to lead me by the...
1
by: Constantine AI | last post by:
Hi i am trying to get User input if data does not exist within a DLOOKUP table. I have gotten it to work for one record but not multiple, i have tried to incorporate my code into a loop procedure but...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.