Help with form on database

G

Guest

Yes I need some help with my database form..what I'm trying to do is I have a
text box with a ID, and two other text boxes with the last name and first
name. What I want to do is enter the Id in the first taxt box and automatical
the last name ans first name would come in their text boxes.

Thanks
 
W

Wayne Morgan

In the AfterUpdate event of the ID textbox, try the following:

Me.Recordset.FindFirst "ID=" & Me.txtID

This will move the form to the record that has the ID you've entered. If
you're not wanting to do that, but instead just "look-up" the first and last
names and place them in the textbox to start a new record, then in the ID
textbox's AfterUpdate try:

Me.txtFirstName = DLookup("[FirstName]", "[TableName]", "[IDField]=" &
Me.txtID)
Me.txtLastName = DLookup("[LastName]", "[TableName]", "[IDField]=" &
Me.txtID)
 
G

Guest

This is not working...is there another way what text box am i entering this
info in?....When I enter the Id # in the first text box what I want it to do
is fill the first name and last name automatically. Does this sound to
confusing. It's driving me crazy cause I know it can be done.

Wayne Morgan said:
In the AfterUpdate event of the ID textbox, try the following:

Me.Recordset.FindFirst "ID=" & Me.txtID

This will move the form to the record that has the ID you've entered. If
you're not wanting to do that, but instead just "look-up" the first and last
names and place them in the textbox to start a new record, then in the ID
textbox's AfterUpdate try:

Me.txtFirstName = DLookup("[FirstName]", "[TableName]", "[IDField]=" &
Me.txtID)
Me.txtLastName = DLookup("[LastName]", "[TableName]", "[IDField]=" &
Me.txtID)

--
Wayne Morgan
MS Access MVP


teelee said:
Yes I need some help with my database form..what I'm trying to do is I
have a
text box with a ID, and two other text boxes with the last name and first
name. What I want to do is enter the Id in the first taxt box and
automatical
the last name ans first name would come in their text boxes.

Thanks
 
G

G. Vaught

What is the intent of the form?

Is the form based on a table other than where the ID Firstname and LastName
resides?

If the ID textbox is a combo box connected to the table where the ID
LastName FirstName resides, then you can add the three fields against the
combo box and then create a text box for the First Name, Last Name to fill
in using code against each field to retrieve the data.

The control source for each textbox would contain code something like this:
Guessing on the syntax.

=cboName.Column(1) for First Name if First Name is the second field in the
combo box. Remember Access starts count at 0. So if the order of the fields
in the combo box is ID FirstName LastName, the numbering would be 0,1,2
respectively.

cboName would be the name of your textbox and Column(1) is written verbatim.
 
G

Guest

This is all new to me, I'm really not sure...I did my table and my form I'm
just having a really hard time with this...can I send you a copy of this form
and maybe you can see what I'm taking about?
 
W

Wayne Morgan

The description I gave was general. You need to change the names of the
objects to match yours (textboxes, tables, fields, etc).

Where are these names coming from (table) that you want to fill in the 2
textboxes? What table is the form bound to (Record Source)?
 

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