473,508 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3184
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
2324
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
338
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
2053
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
3455
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
1622
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
2461
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
2263
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
9024
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
3629
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...
0
7223
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
7321
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
7377
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...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
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...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.