By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 994 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Getting data from a table to a form based on a value

P: 68
Hi every body,

I have 2 tables the first one includes:

# ID.
# Employee's name. etc........

the other one:

# ID.
# Course. etc..................

now, I created a form for the second table and a text box which is irrelated to my database.

The problem that I want to enter the ID in the form and get his name from the first table into that text box.

Could you please help me?
Nov 4 '08 #1
Share this Question
Share on Google+
3 Replies


P: 68
Please give me a hand here I'm wating you.
Nov 5 '08 #2

missinglinq
Expert 2.5K+
P: 3,532
The exact syntax depends on whether the Employee ID is Text or Numeric.

Where

txtEmployeeID is the field on your second form where you enter the ID

txtEmpName is the field on your second form to hold the employee's name

EmployeeTable holds employee name and ID

EmployeeName is the field in your first table

EmployeeID is field in your first table

If EmployeeID is Numeric
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtEmployeeID_AfterUpdate()
  2.  'EmployeeID is Numeric
  3.  Me.txtEmpName = DLookup("EmployeeName", "EmployeeTable", "[EmployeeID] = " & Me.txtEmployeeID)
  4. End Sub
If EmployeeID is Text
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtEmployeeID_AfterUpdate()
  2. ''EmployeeID is Text
  3. Me.txtEmpName = DLookup("EmployeeName", "EmployeeTable", "[EmployeeID] = '" & Me.txtEmployeeID & "'")
  4. End Sub
Welcome to Bytes!

Linq ;0)>
Nov 5 '08 #3

P: 68
Thanks genius it works.

Have a nice day.
Nov 6 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.