Okay, I got a Access database with 1 table (lets call it sectorDescriptions) who contain two column, one who contain the code of all the sectors of activity and the other who contain the name of the sector of activity. Then I got another table (lets call it... ClientInfo) who contain MUCH MORE column but one of those column which is a dropdown list who contain the code of the sector of activity from the table of sectorDescriptions. Now heres my question, I made a form out of the table ClientInfo and now I want that when the user pick a new sector code from the dropdown list, the box named sector name change to the matching sector name based on the sector code! LOL worst question's formulation ever! Sorry for that but I am tired and I'm not really good in english!
Your combo box (cboFilter in this example) should have recordset property something like this:
SELECT [sector code], sectorDescriptions FROM sectorDescriptions ORDER BY [sector code];
If you don't want people to see the Description, just set the column width to 0"
On the after update event of your combo box, put something like this:
Me.txtDescription = Me.cboFilter.Column(1)
Related
I have 3 tables:
tbl1Artist:
ID - (PK),
ArtistName,
ArtistSKU
tbl1Medium:
ID - (PK),
MediumType,
MediumSKU
tbl1Artwork:
ID - (PK),
Artist_ID - (FK),
Medium_ID - (FK),
PieceName,
DateCompleted,
ArtWorkSKU,
Thumbnail
I want to create a form that has a ComboBox for choosing an Artist and a separate ComboBox for choosing the medium type. There will be a TextBox for inputting the name of the piece and a date picker (ComboBox). I need to concatenate the ArtistSKU based on the choice from the Artist with the MediumSKU based on the choice from the Medium ComboBox, and the first 5 letters of the PieceName from the TextBox.
I have done some research to try and figure out how to achieve this but with no luck. Can this be achieved inside of Access with queries or is VBA required to achieve the intended outcome?
I am not that familiar with Access and appreciate all the assistance and guidance.
Let me know if you need further information about this request.
This can be accomplished with expression in query or textbox. Use Left() function to extract first 5 characters.
Example in textbox:
=[cbxArtist] & [cbxMedium] & Left([tbxPiece],5)
If the value you want is actually in another column of combobox list, reference that column by its index. Index begins with 0.
=[cbxArtist] & [cbxMedium].Column(1) & Left([tbxPiece],5)
If you want to save calculated value to table, that would require code (macro or VBA), however, advise not to save. Saved calculated values can become 'out of sync' with raw data. This value can be calculated when needed. But if you must, then code would be like:
Me!ArtWorkSKU = Me.tbxArt
The real trick is figuring out what event to put this code into. Try the form BeforeUpdate event.
Please help me with the following topic.
I'm having a hard time inserting a form in which i need to select from a drop down list the name of the project and below to display the data from the ProdFinit column.
I've tried using combo but i'm new to Access and i thing i'm missing something.
Thank you for your help!
You're on the right path using a combobox. Look at the format tab on the design properties for your combobox. Here I have a form where the user inputs the zip code, but I also want the user to identify the city and state at the same time. My column count is 3 and I chose how wide to make those columns on the next line down. Beware what column to bind it to on the datatab of the properties box. I find binding it to column 1 is easiest.
ComboBox Properties
Zipcode Combobox
Short form of the question:
How can I set a filter for the form which is used by the "List Items Edit Form" property of a ComboBox?
Long description of the environment:
In my database, there is a growing number of structurally similar values which describe something. I collated all of these in one table named ComboTexts, and added a second table ComboTextTypes to customize the field names on the user side. Example:
ComboTexts table:
ID s1 s2 s3 TypeID
1 1 First Floor Ground Floor 2
2 2 Second Floor Null 2
3 AOX DIN 1485 determination of organic components 3
ComboTextTypes table:
ID formtitle ch1 ch2 ch3
2 Floor Floor Number Floor Name Alternate Name
3 Process Process name Standard Description
In order to edit entries in ComboTexts, I provide two forms: The form CoreData displays the list of formtitles from ComboTextTypes and an "edit" button. When the user selects a fomtitle and clicks "edit", the form EditComboTexts is called with a filter for TypeID set. EditComboTexts extracts the TypeID from its filter and modifies itself with the information from ComboTextTypes.
So far there exist 14 ComboTextTypes in the database, and that number is growing. I simply didn't want to have 14 or more tables and forms, which basically all do the exact same thing. Instead I just have two tables and forms, although a little more complicated ones.
The above mechanic is all set up and works fine.
Description of the problem:
The users want to be able to modify the 14th ComboTextType from inside the combobox. The detour through CoreData is three clicks too many, they know that ComboBoxes can offer an edit button for their value list, and want to use it at that point.
Access offers the "List Items Edit Form" for this purpose. When I enter the EditComboTexts form there, it's working in principle, but (of course) the filter is wrong.
How can I set a filter for that form?
You can filter the rowsource using SQL and simply change the rowsource value of the combo box
Me.Combo0.RowSource = "SELECT myfield FROM Table2 WHERE Table2.myfilter = 'value' ; "
I'm working on a small little project, at the moment just a test for a larger project, but I've hit a block that I can't find a solution too.
I have a list of items in a table, and they contain information such as the item name and the price. I have another table with sales. I have a form that will allow you to select a item name, however, then I would like the rest of the form to be auto-filled with information from the items table.
I can make a message box appear when the item name field has been changed, however, through my searching, I am unable to find a way to search the items table for the value of the field, then read the price value, then insert the price value into a field in this form.
First table "items":
itemname: text
price: currency
Second Table "sales":
itemname: text
price: currency
date: time/date
I hope I have explained myself well enough, if not, just ask and I will try to clarify.
Have a look at the Northwind datatabase (northwind.mdb) that ships with Access. They have several examples of how to update a form based upon a combobox changing values.
Also, you might want to look at the table design in the Northwind Database as well. Generally speaking, it is a bad idea to use the product name as the key field in both of your tables. What will happen (and it will eventually) is that the product name is going to change for one of the products and you'll have to update all of the tables that reference that product name.
The better design is to use a key field (I'd recommend an AutonumberField) in your products table and then reference the key field in the sales table. This way, if the product name changes you only have to make the change in one location, not many.
Here's a sample table layout to illustrate my point:
Table Items:
ItemID (Autonumber - Primary Key on the table)
ItemName (Text - Name of product)
Price (Currency)
Table: Sales
ItemID (Integer - Foreign Key to Items.ItemID)
Quantity (Integer - # of units ordered)
Price (Currency)
OrderDate (Date/Time)
Most answers here are posting way too much code and all kinds of SQL statements. As such, these answers are creating world poverty.
The most simple approach is to let the wizard build a combo box on your form to select a given item. This combo box will thus based on the items table. The first column of the combo box will be the PK (autonumber ID) of the items table. This combo box will thus be bound to the ItemID column in sales. The wizard will also “hide” the id, but you WANT to include the other columns in this combo box such as price etc. And you likely should have the 2nd column of this combo box the description of the item from the item table. As noted, you ALSO want to include the price column.
Thus, after you select a item, then to have auto matic fill out the price column, use this code:
This code goes in the AFTER update event of the item combo box:
Me.Price = me.ItemComboBox.column(2)
So when you select a item, the price field will to auto filled for you. And note how you only had to write one line of code.
So all of this can be done using built in wizards and one line of code.
Add an event procedure (code builder) to the dropdown box's onchange event. Right click the dropdown in design view and choose properties. then on the event tab in the properties window click in the on change line and click the '...' button.
In the code for this event you'll need to query the DB (using the dropdown box's index or ID field) to pull the items details into a recordset. The query would look somethign like
"SELECT * FROM Items WHERE ItemID = " & dropdownboxname.value
theres plenty of examples of how to do this on the web
Then you can update the various textboxes in the form with the required fields in the recordset. again theres plenty of examples of this on the web
EDIT:in response to comments below
you'll need to do somethign along the lines of...
Dim rsItems AS DAO.Recordset
Set rsItems = CurrentDB.OpenRecordset("SELECT * FROM Items WHERE ItemID = " & dropdownboxname.value)
If not rsItems.EOF Then
textbox1.text = rsItems![fieldname1]
textbox2.text = rsItems![fieldname2]
end if
Set rsItems = nothing
let me know if thats any help ;-)
I've been assigned the task to design a temporary customer tracking system in MS Access 2007 (sheeeesh!). The tables and relationships have all been setup successfully. But I'm running into a minor problem while trying to design the data entry form for one table... Here's a bit of explanation first.
The screen contains 3 dropdown boxes (apart from other fields).
1st dropdown
The first dropdown (cboMarket) represents the Market lets users select between 2 options:
Domestic
International
Since the first dropdown contains only 2 items I didn't bother making a table for it. I added them as pre-defined list items.
2nd dropdown
Once the user makes a selection in this one, the second dropdown (cboLeadCategory) loads up a list of Lead Categories, namely, Fairs & Exhibitions, Agents, Press Ads, Online Ads etc. Different sets of lead categories are utilized for the 2 markets. Hence this box is dependent on the 1st one.
Structure of the bound table, named Lead_Cateogries for the 2nd combo is:
ID Autonumber
Lead_Type TEXT <- actually a list that takes up Domestic or International
Lead_Category_Name TEXT
3rd dropdown
And based on the choice of category in the 2nd one, the third one (cboLeadSource) is supposed to display a pre-defined set of lead sources belonging to the particular category.
Table is named Lead_Sources and the structure is:
ID Autonumber
Lead_Category NUMBER <- related to ID of Lead Categories table
Lead_Source TEXT
When I make the selection in the 1st dropdown, the AfterUpdate event of the combo is called, which instructs the 2nd dropdown to load contents:
Private Sub cboMarket_AfterUpdate()
Me![cboLead_Category].Requery
End Sub
The Row Source of the 2nd combo contains a query:
SELECT Lead_Categories.ID, Lead_Categories.Lead_Category_Name
FROM Lead_Categories
WHERE Lead_Categories.Lead_Type=[cboMarket]
ORDER BY Lead_Categories.Lead_Category_Name;
The AfterUpdate event of 2nd combo is:
Private Sub cboLeadCategory_AfterUpdate()
Me![cboLeadSource].Requery
End Sub
The Row Source of 3rd combo contains:
SELECT Leads_Sources.ID, Leads_Sources.Lead_Source
FROM Leads_Sources
WHERE [Lead_Sources].[Lead_Category]=[Lead_Categories].[ID]
ORDER BY Leads_Sources.Lead_Source;
Problem
When I select Market type from cboMarket, the 2nd combo cboLeadCategory loads up the appropriate Categories without a hitch.
But when I select a particular Category from it, instead of the 3rd combo loading the lead source names, a modal dialog is displayed asking me to Enter a Parameter.
alt text http://img163.imageshack.us/img163/184/enterparamprompt.png
When I enter anything into this prompt (valid or invalid data), I get yet another prompt:
alt text http://img52.imageshack.us/img52/8065/enterparamprompt2.png
Why is this happening? Why isn't the 3rd box loading the source names as desired. Can any one please shed some light on where I am going wrong?
Thanks,
m^e
===================================================
UPDATE
I found a glitch in the query for the 3rd combo.. It wasn't matching up with the value of the second combo. I fixed it and now the query stands at:
SELECT Leads_Sources.ID, Leads_Sources.Lead_Source
FROM Leads_Sources
WHERE (((Leads_Sources.Lead_Category)=[cboLead_Category]))
ORDER BY Leads_Sources.Lead_Source;
Those nasty Enter Param prompts are GONE!!! However, the 3rd combo still stubbornly refuses to load any values. Any ideas?
Never mind. Found the fix. The BoundColumn property of the second combo wasn't set to the correct column. Hence the selection values in it were incorrect and the 3rd combo wasn't able to refer to the linked table properly (with the correct index).
Job done :)
Thanks to all who may have taken time out to review the problem.