473,779 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving info from another table in a form.

Hi,

I am working on a form in which in a certain field a number of an employee
can be entered. After entering this number I would like to show in the same
form (real time) the name etc. of this employee. This information is stored
in a different table.

Does anyone know how this can be done?

Thanks.

Frank
Nov 13 '05 #1
3 2158
Frankie wrote:
Hi,

I am working on a form in which in a certain field a number of an employee
can be entered. After entering this number I would like to show in the same
form (real time) the name etc. of this employee. This information is stored
in a different table.

Does anyone know how this can be done?

Thanks.

Frank


The easiest method in your case would be the DLookup function.

The more difficult but faster method would use a recordset (see help)
and FindFirst (see help)
Nov 13 '05 #2
It may be a good idea to have this text box at the top of your form
with a button next to it, indicating to the users they are to type in
the information and then hit the button so the rest of the form will
use that info they typed in for the remainder of the form. If this is
the case, you can put code in the click event of the button to do your
connection to the table and pull all the info you need based on the
employee number, then populate the fields with it:

private sub cmdGetEmployeeI nfo_Click
dim sql
Dim con, rs as object
Set con = Application.Cur rentProject.Con nection
Set rs = CreateObject("A DODB.Recordset" )

sql = "Select empName, empEtc from tblDifferentTab le where empId = "
& txtEmpID.value & "
rs.open sql, con, 1
txtEmpName = rs.fields("empN ame")
txtEmpEtc = rs.fields("empE tc")
rs.close
set rs = nothing
set con = nothing
end sub
This is assuming empId is a number field, if it's a text field, you'll
have to wrap ' (single quotes) around the double quotes in the sql
statement. You could probably also do this in the after update event
of your text box.

Also, if the text box to enter the employee number's only purpose is
to type in numbers of employees that already exist, and you don't have
a large number (more than 100 or so), then you could probably change
it to a combo box to make it easier for you and users. make sure you
set the limit to list property to yes - that way they can select one
from the pulldown or start typing and it will auto-complete when you
get it close enough. If you go the combobox route, add the code above
to the after update event of the combobox, and change the txtEmpID
part to the name of your combobox.

"Frankie" <f.*********@ti scali.nl> wrote in message news:<41******* *************** @dreader2.news. tiscali.nl>...
Hi,

I am working on a form in which in a certain field a number of an employee
can be entered. After entering this number I would like to show in the same
form (real time) the name etc. of this employee. This information is stored
in a different table.

Does anyone know how this can be done?

Thanks.

Frank

Nov 13 '05 #3
Okay, it's working now. Thanks.

But...

when I go to the next or previous record the employee's name doesn't
change. I somehow must renew the field (employee's name) but I don't know
how to do this.

Can anyone help me out?

Thanks.

Frank
"user_5701" <us*******@hotm ail.com> schreef in bericht
news:f1******** *************** ***@posting.goo gle.com...
It may be a good idea to have this text box at the top of your form
with a button next to it, indicating to the users they are to type in
the information and then hit the button so the rest of the form will
use that info they typed in for the remainder of the form. If this is
the case, you can put code in the click event of the button to do your
connection to the table and pull all the info you need based on the
employee number, then populate the fields with it:

private sub cmdGetEmployeeI nfo_Click
dim sql
Dim con, rs as object
Set con = Application.Cur rentProject.Con nection
Set rs = CreateObject("A DODB.Recordset" )

sql = "Select empName, empEtc from tblDifferentTab le where empId = "
& txtEmpID.value & "
rs.open sql, con, 1
txtEmpName = rs.fields("empN ame")
txtEmpEtc = rs.fields("empE tc")
rs.close
set rs = nothing
set con = nothing
end sub
This is assuming empId is a number field, if it's a text field, you'll
have to wrap ' (single quotes) around the double quotes in the sql
statement. You could probably also do this in the after update event
of your text box.

Also, if the text box to enter the employee number's only purpose is
to type in numbers of employees that already exist, and you don't have
a large number (more than 100 or so), then you could probably change
it to a combo box to make it easier for you and users. make sure you
set the limit to list property to yes - that way they can select one
from the pulldown or start typing and it will auto-complete when you
get it close enough. If you go the combobox route, add the code above
to the after update event of the combobox, and change the txtEmpID
part to the name of your combobox.

"Frankie" <f.*********@ti scali.nl> wrote in message
news:<41******* *************** @dreader2.news. tiscali.nl>...
Hi,

I am working on a form in which in a certain field a number of an
employee
can be entered. After entering this number I would like to show in the
same
form (real time) the name etc. of this employee. This information is
stored
in a different table.

Does anyone know how this can be done?

Thanks.

Frank

Nov 13 '05 #4

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

Similar topics

3
5308
by: Tom Turner | last post by:
Here's the background on my situation. The question follows --- We have 600 units of mail going from our business to various Post Offices every morning. Every unit is accompanied by a paper Verification form which is signed and dated by a postal employee and returned to our office as proof of delivery. The Verification contains a 24 character barcode which holds a non-unique 5 digit postal zip code at pos 5-9, and a unique 10- digit...
13
3959
by: RHPT | last post by:
I am wanting to capture the XML posted by an InfoPath form with .NET, but I cannot figure out how to capture the XML stream sent back by the InfoPath form. With Classic ASP, I could just create an MSXML object then load the XML with a simple objXML.Load(Request). This would give me the XML stream, which I could then manipulate. However, using System.Xml, this is not possible - not that I have found, anyway. The InfoPath documentation...
1
3895
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://domain") Dim mySearcher As New DirectorySearcher(enTry) Dim resEnt As SearchResult mySearcher.Filter = ("(objectClass=*)") mySearcher.SearchScope = SearchScope.Subtree
2
6394
by: RSH | last post by:
I am struggling a bit trying to get at all of the Table names in a given Access database. I have the code below which should be retrieving the information...i am just having a bit of trouble displaying the Table names out of the datatable. Thanks for any assistance you might be able to offer! Ron
3
1935
by: corear | last post by:
I have a new case tracking system. The cases table has these fields: CaseID (Primary Key) StatusID (looked up in another table - Open, Pending, or Closed) Status Comment (memo field) Date&Time (when casse was opened) ProjectID (looked up in another table - various projects are listed there) CustomerID (looked up in another table - list of names and other info for each) Request (memo field) Result (memo field)
2
2008
by: 4Ankit | last post by:
hello all, i am having some difficulty retrieving information from my form. I want to add content in my table but the content i want to add to the table is what the user inputs in my form. Basically i want to know how i retrieve information from the form so i can disaply it in the table. i have put the code i am using below, the feature i cannot get to work is the change content function. I want the email address entered by the...
0
3396
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to retrieve any of the dynamically created values. I can view them on the source page but can't pull them...
1
3606
by: cumupkid | last post by:
II am trying to create a form that will allow me to upload photos to a folder in the site root directory and add the information to the mysql db at the same time. I have created two forms, one that uploads to photo to the folder in the site root diorectory. One that uploads the info to mysql database. but... When I try to upload them both ways at the same time i cant get it. I am Including code for both pages i have working. Code for...
34
2579
by: vpriya6 | last post by:
Hi guys, I am new to Ajax, xml and javascript. I want to know how can I retrieve data from xml and display in the html page? please help me out. suppose my xml file is customer.xml the code is below: <CUSTOMER>
0
9632
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10302
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7478
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5372
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.