VBA Access - Automatically Populate List
Jul 8, 2007
I wish to automatically fill in a form in datasheet view with records from a table. Currently you need to select each record to fill the list. I think this can be done using VBA, I'm a begininner to programming but think I need the code to do something like this.
Lookup the table or query, DoCmd select the first record, DoCmd select next record, Loop to end of recordset??
Basically it is automatically entering/ filling in each row (record) in the datasheet for every record in that table or query.
Any idea's please.
View Replies
ADVERTISEMENT
Dec 10, 2004
i have a form frmCreditNote with a subform sfrmCreditNote. They are linked by a creditNoteNumber.
As soon as i pick a customer in the main form, i want the first line of the subform to have that customer name as well.
If I change the customer name in the main form, I need the first line of the subform to correspondingly change as well.
If the form was new, i would open a recordset and use .AddNew to put in the new first line date
If I was updating the form customer name, then I would need a .Edit to change the first line of the subform.
My question is : how do I determine if the subform is empty? Is it a command likeIf subform.HasData, orIf IsNull(?)Please let me know thanks
View 1 Replies
View Related
May 21, 2015
I made a bunch of tables by importing them from excel. Then I had someone ask me a question regarding a specific instrument. My tables have a bunch of parts and id's but I don't have the instrument associated with a specific part in the table.
Is it possible to add the data into the new column automatically using a query. I tried the append query, but I'm either doing it wrong or it won't do what I'd like it to do. I just want every record within that table to have the same instrument in an instrumentId column.
View 3 Replies
View Related
Jan 10, 2014
I have a form with a date of when training was completed. I would like to set it up so it displays the date of expiration which is one year from when the training was complete.
View 2 Replies
View Related
Nov 23, 2012
How to populate a list box using another list box on the same form. I have this working completely fine if the the source list box has the multi select property configured to be off, however I need it to be set to extended multi select.
View 1 Replies
View Related
Aug 2, 2005
I have a form where all records are listed on one page with a vertical scrollbar (all simple textboxes):
----------------------------------------------
PrimaryKey Name ForeignKey
----------------------------------------------
1 Pam 20
2 John 20
3 Kim 20
4 Larry 20
... underneath these on the form is a blank record for NEW additions, which obviously has nothing in any of its textboxes, waiting for user to input some data, as normal.
The Foreign Key, due to the nature of my DB, will always be the SAME value for each record in the DB (don't ask, it's part of an export/import-to-main-db app). So I know that the NEW record, if created, will have the same value as the rest of the records.
How do I get it so that when a new record is created, the Foriegn Key textbox is automatically filled in with the value from the row above? (Due to referential integ reasons the Foreign Key field MUST be filled in accuratly or else an error ocurrs.)
Looking at the various events, I realise that it is the BeforeInsert event that will sort this out, but I'm at a loss regarding how to get the NEW record's Foreign Key textbox to match the Foreign Key value above it.
Any advice?
View 4 Replies
View Related
Jun 22, 2007
Mehere,
I think that you can help me with my problem, similar to the one presented here.
I have a form that, when I select an account number, I want the Group to automatically populate on the form.
Below is the code I input on the 'OnChange' event of the 'Group' field on my form:
strFilter = "OracleAccountNumber = '" & Me!OracleAccountNumber & "'"
Me!Group = DLookup("Group", "Accounts", strFilter)
OracleAccountNumber is the name of the field on my form, and it is the name of the combo box in the table that I want to lookup.
Accounts is the table where I want to lookup the OracleAccountNumber
Group is the field from the Accounts table that I want to automatically populate.
What do I have wrong?
View 1 Replies
View Related
Aug 5, 2013
I have a training log that has 4 tables, the employee table, the training course table, and the department table.
These tables all contain the names of employees, training courses, and department in one field and their respective ID codes in the other.
The 4th table is the actual log where the manager logs in who took the training courses. When the manager goes to select the employee name, course name, and department name is there a way not using VBA for the respective ID number to appear in the 4th table (they use the same field names and are related)
View 4 Replies
View Related
Aug 5, 2013
Is there a way to have a date field populate automatically when a form opens but be able to change that date if need be?
View 4 Replies
View Related
Mar 25, 2007
Is it possible to populate several fields on a form via a Nma e selected from a list box ie: the list box has several names in it, the names have data from another form (user details) such has Payrole No:, Holiday entitlement, etc.
I want to select a name from the List Box and have it populate (enter) data into field in the form being used.?
View 5 Replies
View Related
May 29, 2006
Hi there,
I am finally underway with the forms etc, after having spent weeks planning and setting-up the table/relationships.
I have entered some sample data so that I can test out the forms as I go.
I have an "Unbound" list box and an "Unbound" combo box, (along with other stuff) on a form.
The list box gets it's data from a Junction Table between "Customers" and "Products".
I can get the list box to populate itself with ALL the product items in the junction table but I have tried and tried to filter the items down to match the selected value in the combo box.
A couple of diagrams (jpegs) can be viewed here
If anyone could spare the time to enlighten me on this "blind-spot" I would appreciate it very much.
Thanx
View 3 Replies
View Related
Jun 29, 2005
In my list box I have two coloums, Surname and Christian Name, now can I get both names to go into a text field. I can get one of the names i.e surname or christian name by changing the bound coloum from 1 to 2. But I need both names to go across?
View 2 Replies
View Related
Oct 28, 2013
So Im trying to populate the listbox using string connection and having this error: "the object you entered is not a valid recordset property"
here's the code:
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = New ADODB.Connection
cnn = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=xxx;DATABASE=xxx;Port=xxx;USER=xxx; PASSWORD=xx;OPTION=3;"
[code]....
Where is the error??? am doing right or is there any better way to populate listbox from string connection.
View 8 Replies
View Related
Aug 7, 2006
This is probably something already talked about, but if i have a combo box that has an "Add New Entry" selection in it, and when the user clicks on it, i want to add what they want in to the table that the combo box chooses from. can I have that "Add New Entry" selection open a form with a text box, and then have that value enter into the table? What is the easiest way to do this?
View 3 Replies
View Related
Jan 5, 2005
hello all
i have a problem, i have a form bounded to a query
that displays the books infos, in this form i have a list control
that displays the list of authos based on the code of the book
the problem is when i have more than one record in the opened
form ie more than one book and i move to the second record
the list doesnt change and displays the authors of the first book
when the form first opened
anyone has an idea how can the list be updated automatically when
i move between records
thanks a lot
View 6 Replies
View Related
Jul 12, 2007
I have a listbox call lst with two columns, what I want to do is to populate this two column with "firstdata" and "seconddata" respectively.
What I do is:
Me.lst.RowSource = """firstdata""; ""seconddata"""
But I see nothing appear, what is the corect way to achieve in vba?
View 1 Replies
View Related
Nov 9, 2006
Hi all,
I need some help with regards to a small db application im developing.
I currently have a form that contains two separate list boxes.
The first contains "Measures" and the second "Dimensions". They are based on the underlying tables Measures and Dimensions respectively.
My intention is to be able to select whatever Measures I want and select the dimensions they relate to in the other list box then click on a command button to run a query that would update/append my underlying table, Measures2Dimensions, which is linked to the tables that the list boxes are based on.
I hope I've described my problem well enough for someone to provide me with some help.
Many thanks in advance!
View 4 Replies
View Related
Nov 28, 2005
I have three list boxes on a form (lstSubjectName, lstTargetGrName, lstCountryName). The list boxes are populated from queries
based upon tables that have a many-to-one relationship to the main table. The
queries are the following:
SELECT tblProjectSubject.ProjectID, tblProjectSubject.SubjectName
FROM tblProjectSubject
WHERE (((tblProjectSubject.ProjectID)=[Forms]![frmViewPro]![ProjectID]))
ORDER BY tblProjectSubject.SubjectName;
SELECT tblProjectTargetGr.ProjectID, tblProjectTargetGr.TargetgrName
FROM tblProjectTargetGr
WHERE (((tblProjectTargetGr.ProjectID)=[Forms]![frmViewPro]![ProjectID]))
ORDER BY tblProjectTargetGr.TargetgrName;
SELECT tblProjectCountry.ProjectID, tblProjectCountry.CountryName
FROM tblProjectCountry
WHERE (((tblProjectCountry.ProjectID)=[Forms]![frmViewPro]![ProjectID]))
ORDER BY tblProjectCountry.CountryName;
The form is based on the main table (tblProjects).
I want to re-populate/update the list boxes when the ProjectID on the form
changes. I have tried to use a macro (ProjectID_AfterUpdate) for requery of
the list boxes, but can't get it to work.
Any other solutions? Thanks.
Niels
View 5 Replies
View Related
Jul 10, 2014
I am trying to populate a ListBox with the names of the tables from another database. I have the following function which loops the table names from the database I want. The function is caleld on Form Load and passed into the ListBox but the List Box is empty.The message box in the function does display the table names when called from the form. I just cannot get the list box to populate.
Code:
Public Function ListTables()
Dim db As Database
Dim i As Integer
Dim s As String
Dim tdefs As TableDefs, tdef As TableDef
Set db = DBEngine.OpenDatabase("C:MyPathAnalyzed Tables.mdb")
[code]...
View 5 Replies
View Related
Oct 25, 2013
Is there a function that will populate a field with drop down menu based on two criteria?I want the the fields with first and last name to populate with drop down lists based on the employee code I have inputted in the form and job title from a query.
Path: looks at employee code from form > looks at specific job title from query > pulls out all first names in one field and all last names in another field with the same job title in drop down list from query
Employee Code: 100
Returns all employees' first names in first field with same job title:
Prince
Tina
Greg
Returns all employees' last names in second field of form with same job title:
Fey
William
Jones
Here's what the query looks like in datasheet view:
Code:
Location # First Name Last Name Job Title Employee Code
1 John Smith Technician 100
2 Jane Doe Manager 100
2 Greg Jones Engineer 100
1 Prince William Engineer 100
1 Tina Fey Engineer 100
I've been trying to get dlookup to work, but no luck. Here's one of my formula:
Code:
=DLookUp("[Last Name]", "[Employees tb]", _ "[Employee Code] = Form![Employee Code]" & "[Employees tb]", _ " [Manager]"
SELECT EmployeeCodeONLY.[Employee Code] FROM EmployeeCodeOnly;
SELECT [Employees tb].[First Name] FROM [Employees tb] WHERE ((([Employees tb].[First NAME])=[Forms]![Form1]![Employee Code]));
The first is linked to a separate table that only contains employee codes because query I am working with has duplicates due to multiple records.The second is trying to link both the table and query together to populate only first name.how to include the second criteria, job title, to refine it more.
View 1 Replies
View Related
Aug 28, 2003
I have a MS Access database, which contains three main tables. With these I have a completed table, which holds either Yes/No within it.
One of the tables, I have linked to the Completed table as a list box, which when a job has been completed, either yes or no can be selected.
But, what I want to happen, is, when the Yes is selected, I want Access to insert the date the 'Yes' was selected, so that the employee cannot lie about the date the job was completed.
Hope I have explained this in a good enough fashion.
I don't have a clue how to go about it, could anyone help.
View 6 Replies
View Related
Jul 8, 2012
I want to have a list box, which is populated with information from a table/query, to 'filter' what it displays based on what i type in a text box, but i need it to search multiple fields. E.g. say I have a field called name and another called address, and say there are 3 johns in the name field of the table, i want the list box to filter all the other names out and just show me the johns and update automatically. but using the same text box i would like to also be able to search addresses and filter them.
code for the 'On Change' event of the text box to reload the query in the list box. I need to put in the 'criteria' section of the query, i have sound this so far but unsure if its right for every field in the query:
LIKE "*" & [Forms]![Form1]![txtSearch] & "*"
View 1 Replies
View Related
Nov 10, 2005
I need to create a New Form control for this situation:
If I enter a date into a field and the choice for another field is equal to a certain value. How can I get the date I entered to be automatically populated into another date field.
For example:
If I enter 11/10/2005 in a date field and I choose either "BN", "BA", or "BT" in a text field, I need that date of 11/10/2005 to be automatically populated in another date field on the same form.
Any help is greatly appreciated.
View 2 Replies
View Related
Mar 15, 2006
You veterans have probably heard these questions many times, I've had a search around but couldn't find quite what i was after.
This is my first database.
I have 2 tables, one for customer details, and the other is products (holiday packages)
I have made a product form for staff to input new holiday packages. And for the customer form this is also the order form, so a staff member picks up the phone and gets customer details, name, ph, etc and then asks what holiday package they want. I want this to be a drop down list that always fetches all the packages availiable form the product table and when you choose a package it shows all the details on that package.
I need this all to be on the 1 form, if the staff member has to swap back and forth between customer form and product form to get info on a product this will severly hamper productivity.
If my question is abit hard to understand i can take screen shots of my tables/forms to get a better idea. And if someone can really help me finish this database off i'll pay them somethign for there trouble.
Regards, Chris.
View 8 Replies
View Related
Jun 19, 2015
I have a form set up (in a list box) to show our salespeople what parts they have yet to get out of inventory but have a sales order for. The list box shows a list of all the salespeoples names. My manager wants me to show ONLY the salespeople that have populated fields in this list box. The list box currently shows all the salespeople, but I want to see only the ones that have inventory that has yet to shipped. How do I go about this?
View 4 Replies
View Related
Feb 10, 2014
I have 2 tables.
tblOrderType
1 - Maintenance Order
2 - Breakdown Order
3 - Greasing Order
On my form I have two list boxes: An Order Type List box, and an Area Listbox.What query criteria or VBA code would I use so that I could populate a text box with the relevant order number based on the selections of the list boxes. i.e. MaintenanceOrder & Area Z would display MaintenanceOrderNoZ.
View 2 Replies
View Related