473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Field Autofill Problem

All

I am new to this site and hopefully would have a good time here.

I am new to Microsoft Access and VBA and am currently involved in a project to create a new database for one of our company departments. The problem I am having is as follows( ...I have spent about 2 weeks on this now and is about 5 seconds away from going insane....) :

I have created a new form with a combo box that looks up Last Name and First Name from a employee details table. There are also fields in this table for other details like address,sex,contact number etc. What I am trying to accomplish is to select a first and last name from the combo box on the form and once selected , I want it to autofill all the other text boxes on the form with the relevant personal details of the employee.

I just cannot find any workmethod anywhere which explains how to acomplish this.

I hope anyone will be able to guide a novice like me in the right direction.

Thanks in advance

Bloukopkoggelmander
Oct 18 '06 #1
6 9360
PEB
1,418 Expert 1GB
Hi

Here in the forum there is a lot of posts about this!

You need to use a little VB in the after update event in your combo box

Then type

Me[FirstName]=Me![Combobox].column(2)

This means that your field FirstName will be updated with the value of the column number 3 in your combo box!

:)
Oct 27 '06 #2
Hi there

Thanks for that man. Will give it a go . Fingers crossed it will work.

Thanks
Oct 27 '06 #3
ADezii
8,834 Expert 8TB
All

I am new to this site and hopefully would have a good time here.

I am new to Microsoft Access and VBA and am currently involved in a project to create a new database for one of our company departments. The problem I am having is as follows( ...I have spent about 2 weeks on this now and is about 5 seconds away from going insane....) :

I have created a new form with a combo box that looks up Last Name and First Name from a employee details table. There are also fields in this table for other details like address,sex,contact number etc. What I am trying to accomplish is to select a first and last name from the combo box on the form and once selected , I want it to autofill all the other text boxes on the form with the relevant personal details of the employee.

I just cannot find any workmethod anywhere which explains how to acomplish this.

I hope anyone will be able to guide a novice like me in the right direction.

Thanks in advance

Bloukopkoggelmander
In you are going to AutoFill a Field that is not specifically referenced in the Combo Box based on the First and Last names, then you can use the
DLookup() Function with this basic syntax:

'Looking for an Address based on the First and Last names in tblEmployee and
'shown in the Combo Box

'In the AfterUpdate Event of the Combo Box
txtAddress = DLookup("[Address]", "tblEmployee", "[First]='" & Me![cboName].
Column(0) &"' AND " & "[Last]='" & Me![cboName].Column(1) & "'")
Oct 27 '06 #4
Hi there

I have had a look at the code example you have written(thank you for the effort).

I have tried changing the reference for the combobox to textbox as the fields that will automatically be populated with data once the username is selected from a combobox will be textboxes. This did not work unfortunately.

Here is a explanation of what I have :

Tablename : Employees
Field name 1 : Employeenumber
Field name 2 : EmployeeFirstName
Field name 3 : EmployeeLastName
Field name 4 : AddressLine1
Field name 5 : AddressLine2
Field name 6 : AddressLine3
Field name 7 : HomeTelephone

On the form I have a ComboBox which dispalys the username(This is done via an expresison which pulls together Filedname 1 & Fieldname 2. ) The users is then suppose to select a name from the dropdown list.

Once the name has been selected, the rest of the Textboxes which corresponds to Fieldnames 1,4,5,6,7 should autopopulate with the data corresponding to the username selected.

Hope this makes more sense of what I want to achieve.

Thanks
Nov 3 '06 #5
PEB
1,418 Expert 1GB
So my frien,

In your combobox list add the respective columns that you want to get information about

When they are as columns, in the column property of your combobox modify the number of columns... By default it's 1

If you want that the others columns are invisible in your combobox so assign to them a width = 0

As bound column to your combo box assign the number of co.umn that should be introduced as value in your form field...

And then follow the instructions to reference your respective fields

I repeat:
Imagine you have a Field in your Form named : [EmplyeeName] and this is the second column in your combo box to populate it in the after update event procedure type

Me![EmplyeeName]=Me![Combocvv1].Column(1)

The enumeration of columns begin from 0

:)
Nov 4 '06 #6
Peb, thanks for your reply.

Appreciate you getting back to me. I have manged to sort this in the end, but I will try your suggestion as well ( I can then have a couple of ways doing it in future.).

Here is what I did :

- I created a new query on the table I want to get the data from.
- I then wrote an expression for this query to join the Lastname and Firstname fields as follows:

- FullName: Trim(Tablename.Fieldname for surname) & " , " & Trim([Fieldname for forename])

- I then also included all the fields in the query that will be autofilling the Textboxes I have created on the form.

- I then changed the RecordSource on the form properties to use the new created query .

- For the full name as above, I used a ComboBox and then set the properties for that ComboBox's control source to use the expression I created as above. I then set the following code for the AfterUpdate as follows :

Private Sub (Your combo box name)_AfterUpdate()
Dim rs As Object

Set rs = Me.Recordset.Clone
Dim Test As String
Test = "[The name of the expresion to combine first and last name] = '" & Me![Your combo box name] & "'"
rs.FindFirst Test
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

- I then created all the nessecary TextBoxes I needed and set each individual TextBox's control source properties to point to the corresponding field in the expression above.(This could be selected from the field names presented to you when you click on the dropdown menu for the source).


Presto!!

Now when I select a username, the rest of the textboxes automatically updates with the user's details.

So to all who have helped me, thank you very much.
Nov 6 '06 #7

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

Similar topics

2
by: Ross Lewis | last post by:
Is it possible to autofill a specific field in and Internet Explorer form. I would like to install a program on a client's computer that will automatically fill in a password field with their mac...
0
by: Chris Sharman | last post by:
I'd like to design my pages to work cooperatively with browser autofill features. I've loked around, but can't find any good documentation on supported/unsupported field names...
0
by: Ray Holtz | last post by:
Is it possible to autofill a field based on what is entered into another field in a form? My form has an employee field, and department field. In an Items Table, I have fields FldEmployee, and...
0
by: Randy | last post by:
Hi, I have some comboboxes that are created dynamically at run time based on user actions. I found a procedure on a message board to autofill the combobox text from the dataview that the...
4
by: blg002 | last post by:
All I am trying to do is dynamically fill the "Your Price" field with a number that is the product of the value of "acres" "regularity" and 10. The annoying part is I had it working yesterday and...
3
by: ncsthbell | last post by:
I have a column that is defined as a text field called 'Trip number'. The value may be 'ABC' , '1', '33', whatever the user assigns to it. Now they want me to 'autofill' the TripNumber with the...
5
by: z.ghulam | last post by:
Hi, I have a subform in a main form. When I create new records in the subform I would like the Subform. to autofill with the MainForm. It sounds quite simple, but ive been bustin my brains...
1
by: Pazeh | last post by:
Hello, a first timer here! stumbled upon one of the threads hear while searching on google & the feedback was awesome so I decided to jump in & ask my Q! I'm a newbie in AJAX, but I know my way...
12
by: klbrownie | last post by:
Hello, I am trying to get a date field to autofill based on the date of another date field. I want the autofilled date to be 30 days after the other date. For example, if the user has entered...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.