Forms :: Display Attachment Image Based On Combo Box Selection
Jul 13, 2013
I'm working on a wine database (for ages now...). I'm currently struggling getting the following to work. I have a form in which one can select the name and vintage of a wine using a combo box, after which also a picture will be shown of that wine. I have the pictures as attachments in a table. One can then press a button to close this form and go to another form in which one can edit all the details of the selected wine. Problem: I can't get the picture to show.
I have a reasonably simple form with a combo box, a text box, a button and an attachment field in which a picture should show.
I made a query to select the id, name and vintage from the wine table. I couldn't select the attachment field for the pic in the wizard, so I added that myself in the Design View. The Query for the combo box now reads:
Code:
SELECT Wijn.Id, Wijn.Naam, Wijn.Vintage, Wijn.Plaatje FROM Wijn ORDER BY Wijn.[Naam], Wijn.[Vintage];
(translation: Naam = name | Plaatje = picture)
It neatly shows name and vintage in the drop down list. Once selected it only shows the name of the wine in the combo box and I use VBA to fill the Text Box with the vintage of the selected wine. The VBA I use is:
Code:
Private Sub cmbNaamWijn_Change()
Me.txtVintage.Value = Me.cmbNaamWijn.Column(2)
End Sub
All works fine. Also when I pres the button, the wine I selected opens up and can be editted and the select form nicely closes. The only problem is the fact that I cannot get the picture to show!
I inserted an attachment field with the name: attImage. In the VBA code I added the line:
Doesn't work. With debugging I do see it gets the correct value form the table. I get an error message stating "Method or data member not found", so Picture is not available for the attachment object I guess. If I look at what is available, I can't select anything useful. So my next try was adding an image control with the name: ImageWine and the VBA code in the On Change property
Code:
Me.ImageWine.Picture = Me.cmbNaamWijn.Column(3)
results in the following: Run-time error '2220'. Microsoft Access can't open the file '[FilenamePicture]'. Logical in a way I guess, since there's no path in there. I also tried the Bound Object Frame, but that resulted in the same problem as the attachment try described above.
I have been looking some information on changing image based on form combo box selection on form.
I manage to do case by case but i need it in a simple code because their will be many employees just to avoid adding case by case code for each one.
Private Sub Emp_IDCombo_AfterUpdate() Select Case Emp_IDCombo.Value Case "AM-001" Imageholder.Picture = "C:UsersAMGDesktopam-001.jpg" Case "AM-002" Imageholder.Picture = "C:UsersAMGOne DocumentsHR & Admin DatabaseEmployee Picturesam-002.jpg" End Select
I have employees table where all images location is saved in text field and i have a combo box on form which is employee id.
Tables relationship Employees_table [PK] to Contracts_table [FK] via field name {emp_ID}
Fields Name Combo Box name on form Emp_IDCombo and row source is SELECT Employees_table.Emp_ID, Employees_table.EmployeeName, Employees_table.Emp_Pics FROM Employees_table;
Text field is located in employees_table called [Emp_Pic] for images location.
I would like to write an expression (i presume) to auto fill a text box based on the selection made from a combobox...can anyone help or point me to a tutorial that deals with this??
I am a novice to Access and in order to get some training in my workplace I need to show how access can be applied to my role.
I have a table of information consisting of 3 fields:
Motor manufacturer Model Attachment (picture of particular car)
I want to have someone able to select the manufacturer and Model from Combo boxes and this will pull up the image associated with this model.
There are more than 1 model for each Motor manufacturer so you may have:
manufacturer Model Ford Fiesta Ford Mondeo VW Beetle VW Golf Fiat 500
You must not be able to select the wrong model for manufacturer, i.e. Ford 500
The images are currently saved onto the table as an attachment, This may be wrong as well, This may be a simple task to do, but hopefully I can get it running smoothly and show this is the right tool for the job.
I have an image within the attachment field on a table.The particular table is not linked with the data within the report.I tried to use DLookup but found it only showed the picture name i.e. signature.png..How can I display an image (in fact the only image) in the attachement field on another table within the report?
I am trying to show an image on a form based on a user choice from a drop down box. For example, the user needs to choose a priority for a task. If the user chooses "Immediate" I want an image of an exclamation point to show up to draw attention that this is important.
I have a continuous subform which queries a table of attachments. I'm using Access 2007 but not using the Attachment datatype; this DB will grow considerably and I don't want to waste precious space by filling it with bulky files. So instead, I have code which makes a copy of the attachment and adds the hyperlink (to the copy) to the table instead.
Now - I want to add a control to the subform to display an icon / image reflecting the file type of the attachment (Word doc, Excel s/s, PDF etc.)
But not sure how to go about it.
I was thinking I could use FileSystemObject.GetFileExtension at the point in the code where the attachment is added, and add a new field to my attachments table (i.e. translate "*.xls*" to "Excel", etc.) Then store / embed a handful of images for the core types I would expect and use an image control on the subform to display the image based on the value of that field.
But is that even possible / feasible?
Or, is there a handy API which can retrieve the icon associated with a file type based on what has been installed on the local machine (even if there is, there's still the problem of setting up the image control to display the appropriate icon specific to each record...)
Or, is there another control available which would be better suited to something like this than an Image control?
I'm trying to create an access database to make an inventory of my model trains.
I have a main entry form (frmTrain) where I enter all sorts of info regarding e.g. a locomotive. This info is then stored in a table (tblTrain).
In the main entry form, I've put a combo box (cmbCountries) linked to a query (qryCountries) which queries the country codes from a table (tblCountries) that has three fields:
ID (autonumber) CountryCode (short text) (containing the country codes UK, FR, DE, ...) FlagFile (short text) (containing the name of the flag picture, e.g. UK.png)
The flags are stored as *.png files in a folder Flags that is in the same folder as the database file. I have chosen this approach instead of putting the flag pictures in an OLE field in tblCountries because I'd like to avoid being stuck to *.bmp files (don't support transparency). I'd also like to avoid having to mention the complete file path in the field FlagFile
I created a form (frmCountries) to easily add countries to tblCountries as needed.
Now back to the main entry form. The selection made in cmbCountries is stored in the field 'Countries' in tblTrain. When a country is selected in cmbCountries, I'd like that the corresponding flag is displayed next to the combo box.
I found an example on the web where an image field was used to display the flag, let's say with the following code:
Private Sub cmbCountries_Change() Me.ImageFieldName.Picture = Me.cmbCountries.Column(2) End Sub
Private Sub Form_Load() Me.ImageFieldName.Picture = Me.cmbCountries.Column(2) End Sub
and where the combo box had as row source (not using qryCountries):
SELECT tblCountries.ID, tblCountries.CountryCode, [Application].[CurrentProject].[path] & "Flags" & [FlagFile] AS Expr1 FROM tblCountries ORDER BY tblCountries.[Code];
The problem with this example is that, if you select in frmTrain e.g. UK, the UK flag is then displayed across all records in frmTrain. So the image field is not the appropriate field to display the flag in frmTrain and I guess an unbound/bound (?) object frame should rather be used.
How to display correctly the flag picture for every individual record in frmTrain corresponding to the country chosen in cmbCountries.
I am creating a Database to track product details and inventory for items we purchase.
I have several Tables and several Forms already working properly, except for one thing.
I have a Form called "Lights", and it contains a ComboBox called Light_Name and 6 TextBoxes: Manufacturer, Model_Number, Cost, Weight, Light_Type, Notes. It also has an Attachment Field linked to the same table.
I am using the Code:
Me.TEXTBOX = Me.Light_Name.Column(#)
to populate the Textboxes with the relevant info from the Light Table.
This works for every Textbox I have.
However I cannot get the Attachment Box to change. And when I try to add code to it I get a debug error. The Attachments are PDFs and I need them to show based on the ComboBox Selection.
I have tried the same code as above, and as I said, it gives me an error.
I have a combo box that display three columns but I want the middle column to be the value that displays on the combo box after the selection not the first column. How do I achieve this ?
Project Name Project Number Project Description
I want the Project number to be displayed in the box after selection.
I'm trying to build a database for daily work. My work in daily basis I have to fill all condition for several items.
We have two areas, with two locations under each area, and three systems under each location and each system contain more than 500 items.
I created all tables and fill by all information:
1-Table 1: Area 1, Area 2, Area 3, Area 4, Area 5, Area 6. 2-Table 2: Location 1, Location 2. 3-Table 3: System 1, System 2, System 3. 4-Table 4: all items under System 1-1-1 5-Table 4: all items under System 1-1-2
[Code] ....
Last table will be LogBook which will be as follow:
date l time l area l location l system l item l Conition1 l Conition2 l Conition3
My question regarding to the form of the above table:
How can I make a combo box for area field and when I select for example area1 will appear only the locations which under area1 in location field, and when I select location1 for example will appear only the systems under location1 in system field, and when I select system1 one for example will appear only items under system 1.Combo box list will be based on the selection in previous combo box and so on.
I am trying to auto populate the text boxes in the form based on drop down from the combo box. As you can see in the form Frm_Input, this works fine for FL, but for some reason it will not populate for Skill, Role, FLM and Location. The table it is linking to is Tbl_Names. Why as I have changed the column source?
I am struggling to pull out a report based on the combo box selection. I have NOI database and want to pull out a report for a specific customer that how many NOIs are generated by this customer..
I have a separate table of customer and another table of NCRs and the customer information comes from customer table.
I have tried the below statement but gives me an error message:
code for Macro that pulls the report in click event:
[CustomerName]=[forms]![CustName]![combocust1]
do i need to mention the report as well in some where in report ?
- Form 2 to be locked but its "MaterialRequest" is enabled. - HandledBy to be unlocked if the MaterialRequest meets the "Status" of "frmMaterialRequest" which is "Approved".
I am having issues with my combo box populating values based on the selection from another combo box.
Database : contains 2 tables: Staff_List, Level_Type and a form called frm_Test The first combobox cboLevel gets its value from the Level_Type table with the select statement SELECT [Level_Type].[ID], [Level_Type].[Level_Type] FROM level_Type;
The values to be displayed on the second combobox cbo_Name is expected to be dependent on the Level selection made from the first combobox i.e if Level 1 is selected in cboLevel then only Names of people in Level 1 will be displayed in second combobox.
The select statement I put there is SELECT Staff_List.ID, Staff_List.Staff_Name FROM Staff_List WHERE ((([Staff_List]![Level])=[Forms]![frm_test]![cboLevel])); This is not displaying anything in the second combobox after I tried it in the Form view, just empty.
I have two tables: tblWeightTickets and tblWasteType.
I want to create a form: frmWeightTickets, where a user can enter information and the data is stored in tblWeightTickets.
There are two fields in particular that I am working on ... "WasteType" and "Rate".
On the form, I want "WasteType" to be a combobox "cboWasteType" and when I select a type of waste I want the "Rate" textbox on the same form to auto populate with the rate amount for that particular type of waste (i.e. recycling, garbage, etc).
The Rate amount is located in the table: tblWasteType under the field name "Rate". How can I do this and at the same time store the information in the tblWeightTickets? I already have the combo box loaded with the types of waste - I just need it to populate the rate text box and store it in the Weight Tickets table.
I have frmIncident that has a 2-column combo box (cmbIncidentType). Column (0) is IncidentType, Column (1) is YES/NO. This combo box feeds from a Query and currently has about 15 "types" of which 4 have a "Yes" tied to them, then rest "No".There are situated on a TabControl (tabIncident) with 5 sheet tabs. If the Incident Type selected in the Combo Box has a corresponding "Yes" in Column (1) then all 5 sheet tabs need to be visible. If it is "No", then only three of the five are visible. Here it he current code I am using for the AfterUpdate event on the combo box:
Private Sub cmbIncidentType1_AfterUpdate() If Me.cmbIncidentType1.Column(1) = "Yes" Then pgEmerIncidentRpt.visible = True pgNarrClose.visible = True Else
[code]...
When I open the form is will set the proper sheet tabs that need to be visible, however once I cycle to the next record, or select a different Incident Type, even one with a "YES' in column (1), it will only show the (3) sheet tabs. I can never get it to show all 5.
In the code, the only (2) sheet tabs that need to visible = true or visible = false are shown, starting with "pg".
im trying to enable/disable checkboxes based on a combobox selection for instance,
i make the selection in a combo box called terms and conditions. i want it then to only enable the business,domestic and summary check boxes for that type, with the onther check boxes staying disabled. is there a way this can be done through code like the statement "only enable if this letter type selection has been selected"
I'm creating a form that when the user selects the following categories in the same combo box (Date Received, Date Reviewed, Date kitted, In Work, Complete) it auto populates dates in the respective fields. As I mentioned, it's only one combo box. The dates will be spread out, so the user will change the combo box selection based on when these events occur. I already have a field for each category both on the table and form. Also, I do have multiple tables for other parts of data, but these categories all fall into the same table.
I want to create a text box within a form that automatically populates a contact number based on a selection from a combo box, also in the same form.
For example, I have a Bidders Table (tblTenders), this form includes information regarding the Tendor like the company name and a main contact within that company and a phone number for that contact.
I've created a separate table for all the contacts called tblContacts. This table holds all the contact information for each contact. I have a simple form called frmTenders that asks the user to input the Customer (which is the company who are bidding) and the Main Contact, which is a combo box to select the main contact from tblContacts. Below that combo box is a text box called 'Contact Number' - I want this box to display the contact number for the main contact automatically when a main contact is selected from the combo box.
The contact number text box isn't storing that information in any tables etc. It's just for viewing purposes when we need to make a call to that specific tender.
I have a piece of code that I'm using to display an image on a report based on a path saved to each record. the code is:
Code: Option Compare Database Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) If IsNull(Me.ImagePath) Then Me.ImgPic.Picture = "O:BellinghamIntranetProductionLabelsNo Label.bmp" Else Me.ImgPic.Picture = Me.ImagePath End If End Sub
It seems like every few months the code crashes access and then never works again. When I debug, the part that is highlighted is:
Code: Me.ImgPic.Picture = Me.ImagePath
The only way i've found to correct it is to delete the report and the module and copy them back in from a backup database. What could be causing this code to crash or how to stabalize my database to prevent this from happening again.
I have a form that calculates freight costs. I'm using a combo box for the user to select the route of the shipment from shipping port to destination port. The combo box has 2 fields. The index which is stored in the database and the description which is displayed to the user. I used the wizard to create the combo box and set the index to be saved in a table. Everything works fine, the freight cost is calculated correctly and the data is stored as designed.
The problem is when if the user goes back later and opens the screen to view the freight information, the combo box doesn't display what was selected previously. Therefore, no freight is calculated and the user has to reselect the combo box again. When I check the table, the index value of what was selected is in the table, but it will not display in the combo box.
. . . . Additional info to this post. . . . The combo box is set to use a data from a standard table. The user can only select what is displayed in the list. However, the index is then stored in another table after the selection is made. I want the combo box to do something like, if a selection was previously made then displayed what was select, if not, then display the data from the standard table.
What did I do wrong during the set up? Thanks for your help solving this problem.
i want to see the product image in my database as per my selection from listbox in "frm_MainForm" but it shows error no 2220. database file is attached.
It does show the image when i add it to the form "frm_PruductMaster" and search in "frm_MainForm" but only until i restart application. after restarting application it again shows error 2220. But it shows image name in the error. (i have tried with .bmp and .jpg as well).
I have access2007 Currently i have a tabbed form on one tab i have a combo box to select names.On the following tab i have a text box which i want to display the selection made with the combo box. At first i was just getting a number on reading related issues on this forum i tried =[CMB_salesman].[column](2) unfortunately that gave no result.