Dlookup Function

  • Thread starter kft10 via AccessMonster.com
  • Start date
K

kft10 via AccessMonster.com

Hi,

I have difficulty to create 'Dlookup' function on Form in Access'2003. I'd
like to pull out the 'description' field on 'table1' when I enter the code on
my form. Is any one in forum can give me an idea?

Thank you in advance.

Rgds,
KF
 
B

Brian

It depends on what you mean by "pull out". If you enter some key, for
example, CustomerID, in Table1 and then want to show the description
onscreen, it would be this:

Have a text box called CustomerID. Enter the desired CustomerID. Have this
code in the CustomerID_AfterUpdate event:

Private Sub CustomerID_AfterUpdate()
If IsNull(CustomerID) then Exit Sub
Dim MsgText as String
MsgText = DLookup("[Description]","[Table1]","[CustomerID] = " & [CustomerID])
MsgBox "Description: " & MsgText
End Sub
 
K

kft10 via AccessMonster.com

Thank you for the answer. I wonder, why the 'MsgBox "Descripton" & MsgTex'
didn't appear on the form? Please advice, thank you

Rgds,
KF
It depends on what you mean by "pull out". If you enter some key, for
example, CustomerID, in Table1 and then want to show the description
onscreen, it would be this:

Have a text box called CustomerID. Enter the desired CustomerID. Have this
code in the CustomerID_AfterUpdate event:

Private Sub CustomerID_AfterUpdate()
If IsNull(CustomerID) then Exit Sub
Dim MsgText as String
MsgText = DLookup("[Description]","[Table1]","[CustomerID] = " & [CustomerID])
MsgBox "Description: " & MsgText
End Sub
[quoted text clipped - 6 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top