How can i use dlookup to display data in foreign table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need help using Access 2003, PLEASE. I wish to display customers names if a
customer number entered in a form called daily sales with a sub form based on
the products sold. I have set primary keys and used the expression builder in
the text box properties to display the first & second name (concatenated if
poss), but when i put an exsting customer number it reports an error in the
formulae with no joy on the dlookup function. I would also like to know how
it is possible to send an automated email response to a customer using
Outlook 2003.
 
Dim varCustName as Variant
varCustName = DLookup("[FirstName] & " " & [SecondName],
"CustomerTableName", "[CustomerNumber] = " & Me.CustomerNumber
If IsNull(varCustName) Then
MsgBox "Customer Number Not Found"
Else
'At this point varCustName will contain the First Name, a Space, and
the Last Name. For example, First Name = "John" and Last Name = "Smith",
then varCustName will = "John Smith"
End If

Note: you will need to change the names for you table, field, and control
names.
 
I dont understand what you mean about changing the names of the table, could
you help me further and i am not very good with the VB either, do i enter
this code in the form or is it a global variable. Can this not be done using
DLookup? I thank you for your time and hope you can assist me further.

Klatuu said:
Dim varCustName as Variant
varCustName = DLookup("[FirstName] & " " & [SecondName],
"CustomerTableName", "[CustomerNumber] = " & Me.CustomerNumber
If IsNull(varCustName) Then
MsgBox "Customer Number Not Found"
Else
'At this point varCustName will contain the First Name, a Space, and
the Last Name. For example, First Name = "John" and Last Name = "Smith",
then varCustName will = "John Smith"
End If

Note: you will need to change the names for you table, field, and control
names.
tboyce said:
I need help using Access 2003, PLEASE. I wish to display customers names if a
customer number entered in a form called daily sales with a sub form based on
the products sold. I have set primary keys and used the expression builder in
the text box properties to display the first & second name (concatenated if
poss), but when i put an exsting customer number it reports an error in the
formulae with no joy on the dlookup function. I would also like to know how
it is possible to send an automated email response to a customer using
Outlook 2003.
 
I don't really understand all of your question, but what I mean by changing
the name is that since I don't know the names of your tables and fields, I
made them up to give you an example. You will have to put in your own names.
Without knowing how your form works, I can't tell you where to put the code.
If you can give more information about how you are using it, maybe I can
help.
tboyce said:
I dont understand what you mean about changing the names of the table, could
you help me further and i am not very good with the VB either, do i enter
this code in the form or is it a global variable. Can this not be done using
DLookup? I thank you for your time and hope you can assist me further.

Klatuu said:
Dim varCustName as Variant
varCustName = DLookup("[FirstName] & " " & [SecondName],
"CustomerTableName", "[CustomerNumber] = " & Me.CustomerNumber
If IsNull(varCustName) Then
MsgBox "Customer Number Not Found"
Else
'At this point varCustName will contain the First Name, a Space, and
the Last Name. For example, First Name = "John" and Last Name = "Smith",
then varCustName will = "John Smith"
End If

Note: you will need to change the names for you table, field, and control
names.
tboyce said:
I need help using Access 2003, PLEASE. I wish to display customers names if a
customer number entered in a form called daily sales with a sub form based on
the products sold. I have set primary keys and used the expression builder in
the text box properties to display the first & second name (concatenated if
poss), but when i put an exsting customer number it reports an error in the
formulae with no joy on the dlookup function. I would also like to know how
it is possible to send an automated email response to a customer using
Outlook 2003.
 
I dont understand what you mean about changing the names of the table, could
you help me further and i am not very good with the VB either, do i enter
this code in the form or is it a global variable. Can this not be done using
DLookup? I thank you for your time and hope you can assist me further.

tboyce said:
I dont understand what you mean about changing the names of the table, could
you help me further and i am not very good with the VB either, do i enter
this code in the form or is it a global variable. Can this not be done using
DLookup? I thank you for your time and hope you can assist me further.

Klatuu said:
Dim varCustName as Variant
varCustName = DLookup("[FirstName] & " " & [SecondName],
"CustomerTableName", "[CustomerNumber] = " & Me.CustomerNumber
If IsNull(varCustName) Then
MsgBox "Customer Number Not Found"
Else
'At this point varCustName will contain the First Name, a Space, and
the Last Name. For example, First Name = "John" and Last Name = "Smith",
then varCustName will = "John Smith"
End If

Note: you will need to change the names for you table, field, and control
names.
tboyce said:
I need help using Access 2003, PLEASE. I wish to display customers names if a
customer number entered in a form called daily sales with a sub form based on
the products sold. I have set primary keys and used the expression builder in
the text box properties to display the first & second name (concatenated if
poss), but when i put an exsting customer number it reports an error in the
formulae with no joy on the dlookup function. I would also like to know how
it is possible to send an automated email response to a customer using
Outlook 2003.
 
Can you explain in layman terms for us thicko's. Many thanks for trying to
help out

tboyce said:
I dont understand what you mean about changing the names of the table, could
you help me further and i am not very good with the VB either, do i enter
this code in the form or is it a global variable. Can this not be done using
DLookup? I thank you for your time and hope you can assist me further.

Klatuu said:
Dim varCustName as Variant
varCustName = DLookup("[FirstName] & " " & [SecondName],
"CustomerTableName", "[CustomerNumber] = " & Me.CustomerNumber
If IsNull(varCustName) Then
MsgBox "Customer Number Not Found"
Else
'At this point varCustName will contain the First Name, a Space, and
the Last Name. For example, First Name = "John" and Last Name = "Smith",
then varCustName will = "John Smith"
End If

Note: you will need to change the names for you table, field, and control
names.
tboyce said:
I need help using Access 2003, PLEASE. I wish to display customers names if a
customer number entered in a form called daily sales with a sub form based on
the products sold. I have set primary keys and used the expression builder in
the text box properties to display the first & second name (concatenated if
poss), but when i put an exsting customer number it reports an error in the
formulae with no joy on the dlookup function. I would also like to know how
it is possible to send an automated email response to a customer using
Outlook 2003.
 
Back
Top