How to insert a picture into an access. Inserting objects into a field with the data type ole
To add a background image to an Access form, for example, to the main button form, you need to start the database ("Student performance" with the main button form) and click on the Database Window button on the toolbar. The base window will open access datain which open the Access button form in Design mode.
To add a background image to an Access form, you must open the Button Form Properties dialog box, which you can open in several ways. Let's consider one of the ways: open the Properties window by right-clicking on the button form, and select Properties from the context menu. The Picture: Picture window opens on the Layout tab.
Figure: 1.
To enter the path and name of the picture, click on the browse button, the Select Picture dialog box will open. In this window, you must specify the name and type of the file. By default, Microsoft Office Access supports the .bmp, .dib, .wmf, .emf, and .ico file formats. Therefore, select a picture with one of the specified extensions and click the OK button in the Select Picture dialog box. I chose the .bmp extension for the picture.
Next, in the Picture: Picture window, specify the type of picture, it can be embedded or linked. The main differences between binding and embedding (embedding) are where the data is stored and how the data is updated after it has been placed in a document. Embedded drawing is an integral part access forms, i.e. will be stored in the database, increasing its size.
A linked object is data (an object) created in one file and inserted into another file with support for linking between files. The linked object is not part of the file in which it is inserted, but is stored in the original file in one of the PC directories, without increasing the size of the database. If a picture or company logo needs to be placed on each form and in reports, then it is advisable to insert the picture as a linked object.
I chose the embedded image, since it is an integral part of the Access database, which allows Internet users to copy (download) the database file from the site.
The next step is to set the dimensions of the picture. The scale of the picture has the following meanings:
- Fragment;
- Fit to frame;
- Fit to frame.
Choose one of the values \u200b\u200bdepending on the purpose. In the button form Access Student_Progress I chose the scale of the picture - Fragment, alignment - Center, the result is shown in the figure
Figure: 2.
After closing the "Picture: Picture" and "Button Form: Form" windows, double-click on the "Button Form" button, the following Access Main Button Form with a background image will open.
Figure: 3.
Inserting pictures, photos and logos into forms or reports helps improve them appearance and personalizes the Access database.
Access 2010 has the ability to add objects to a field with data type OLE... In the case when the data type is specified as OLE (Object Linking and Embedding- object linking and embedding), then Access keeps the external an objectin a common database file, allocating as much space for its storage as this object takes up as a separate file. Under objectsshould be understood as files created in the form of applications in graphics editors, video clips, in MS Office applications, etc. When the table is filled with data that are objects, a message about the program with which you can open this object is generated in the corresponding position of the field with the OLE data type. Object display will be carried out only in forms and reports.
For embedding an object in the field with oLE data type you need to open the table in mode "Constructor".Add a new field like "Product photo".Select data type OLE Object Fieldand then save the table.
Then in the "Table" mode in the line for data entry, right-click, in the menu that opens, select the line with the command, which will open a dialog box (Fig. 3.38, Fig. 3.39).
Figure: 3.38 Inserting an Object
Figure: 3.39 Dialog box for adding a new object to the Access table
Remember that there are two possibilities to embed objects as data. The first option provides for the use of standard applications for creating a file that Access supports, the second option for inserting an object, which allows you to use any file as a data source (Fig. 3.40).
Figure: 3.40 Adding a new object to an Access table from a file
1. Creating an object from a file.
When it comes to data, which are objects for the database and are external files, then you need to have these files. Therefore, you will need to create several files in order to see their display in the database in the future, and also try to modify these files. For example, if you have a photo of an object in the file Monitor.jpg (jpg is a universal photo format). In order for this file to be saved in the database, in the window (Fig. 3.40) check the box "Create from file" , after which a window will appear, which is shown in Figure 3.41. Using the button "Overview" select the required file.
Figure: 3.41 Finding a file when creating an object in the database
In the corresponding line for the field e.g. "Product photo" a word will appear "Package", this means that the file is associated with the application with which it was created. Therefore, when viewing the database, whether it be a query, a form or a report, the user will see the image of the file as an icon, and when double-clicking on this image, the system will first find the application, and then display the contents of the file in it (in this example this photo). The only exceptions are image files saved with the extension .bmp (bit map format). However, it should be recalled that files created in Microsoft applications will be displayed immediately in forms and reports. The conclusion is simple, photos can be inserted into applications such as Paint, Word, Power Point, saved as separate files, and then connected as an object to the database. Try to create multiple files with photos and text using different Windows editors. For example, you can open a Word document, insert a photo from the file, add text, and then save as: Monitor.docx(fig. 3.42).
Figure: 3.42 Photo file created in Word
2. Creation of new objects.
The creation of new objects in the database should mean the use of the application in which the file is created, and then connected in the field describing the type of this OLE. To start the mode of creating new objects, you must open the table in mode "Table", choose an option "Create new" in the dialog box (Fig. 3.39), and then select in the list "Object type" (required application). The list of applications that Access supports for creating an object are in the list (Fig. 3.43), which will open after running the command "Insert Object" .
Figure: 3.43 List of Access Object Types You Can Use to Create Files
The convenience of using applications for creating objects in the form of files lies in the fact that in the future these files can be used autonomously or corrected in the database.
Consider object creation option for the database using with paint applications.
For example, you need to create an object with an image of a company and text, which the database user can later replace or correct. To do this, select from the list bitmap Image object, further technology for creating an object is shown in Figure 3.44.
1. Open the Paint app
2. Insert photo from file.
3. Add text (if necessary).
4. Save as file.
5. Close the application.
Figure: 3.44 Object creation technology in Paint
The task 3.11
1. In the table “ Products"In the mode "Constructor" add a new column named "Product photo", data type " OLE Object Field ", save your changes.
2. In the mode "Table" in field "Product photo" select the line "Insert object from file", select (dot) "Create new" and from the dropdown list document Microsoft Word ... This will open a text editor MS Word, here you need to insert a picture corresponding to the product in this line. Select pictures from the list that is stored directly in the editor (the "Insert" tab, the "Picture" icon, the "Start" button in the dialog box on the right), or insert a picture from other programs. You can use the Paint application (Bitmap Image object), where you draw the product yourself. Close the created file, it will automatically be linked to your database, to the line in which it was inserted.
3. Follow this procedure to all lines your "Products" tables.
4. Save your changes.
test questions
1. What objects can be inserted into a database with the OLE data type?
2. How can you insert a photo into a table in the "Table" mode?
3. Where in the database will the photo be displayed?
4. What is the difference between the "Create new object" method and the "Create from file" method?
5. How to put a product photo file into the database if it has the extension .png?
6. Can you edit a file that is inserted as an object into the database directly in the computer's file system?
7. How to insert a presentation into the database?
8. What application objects can I insert into the database?
Access 2002 allows you to specify not only smooth colors as the background of a form, but also bitmap images stored in various graphic formats, such as WMF and BMP. Access 2002 ships with several bitmap graphics, which are stored in the Microsoft OfficeOfficelOBitmapsStyles folder.
To set a background image for a form:
- In Design mode, select the entire shape. To do this, left-click on the square in the upper left corner of the Form Designer window, where the vertical and horizontal rulers intersect. After selecting the shape, a black square will appear at the intersection of the rulers.
- On the toolbar Form constructor (Form Design) click the button Properties (Properties). The form properties window will appear (Fig. 5.24).
Figure: 5.24. Form properties window
- Expand the tab Layout (Format) in the properties window of the form and use the scroll bar to move to the bottom of the list of properties, where the property is located Picture (Picture).
Figure: 5.25. Dialog window Selecting a pattern
- In the property field Picture enter the path and name of the image file or use the Builder: place the insertion point in the field Picture, then press the button Build (Build), which will appear to the right of the field as a small square with an ellipsis on it, after which a dialog box will open Selecting a pattern (Insert Picture) (Fig. 5.25), with which you can find and specify the required picture file. This dialog is standard dialog box opening files in Windows. After the picture file is found, select its name, and then press the button OK. Access will display the path and file name in the property box Picture.
- To close the form properties window, click Close (Close) at the top of the window.
Unlike background colors, the background image applies to all sections of the form. To remove the background picture just remove the content of the property text box Picture.
Also, using the properties grouped in the tab Layout form properties window, you can customize the display of the background image. Property Pattern type (Picture Type) defines the method that Access uses to attach a picture to a form. Select an item from the dropdown list of this property Rooted (Embedded) if you intend to distribute the application between users and the form should not use external files that can be moved or deleted. If there are many shapes that use the same background, then from the drop-down list, select Connected (Linked), which will reduce disk space usage by including a wallpaper on the form by linking to a picture file.
Using the property The scale of the drawing (Picture Size Mode) You can define the size of the wallpaper. To display the picture in its original size, in the drop-down list of this property, select Fragment (Clip). When choosing a value Fit to frame (Stretch) the drawing is stretched or shrunk horizontally and vertically to fit the shape; in this case, it is possible to change the proportions of the picture. Value selection Fit to frame (Zoom) will stretch or shrink the picture proportionally to the maximum possible size without cropping the picture.
To determine the position of the wallpaper, select one of the following property dropdown items Aligning the picture (Picture Alignment): Top left (Top Left), Top right (Top Right), Center (Center), Bottom left (Bottom Left), Bottom right (Bottom Right) either Center of the form (Form Center).
Comment
To have the background image centered on the form rather than the form window, set the property Aligning the picture value Center of the form, not Center.
If the property Mosaic filling (Picture Tiling) is set to Yes, then in the form window or in the entire form (depending on the value of the property Aligning the pattern) a repeating pattern is displayed.
After you change the value of a property, the result of that change is immediately displayed on the form.
Form printing
The form, like any other document, can be printed. First, you need to prepare the form for printing.
1. Open the sample database Sales department.
2. In the navigation area, double-click the name of the form Main form Clientsto open it.
3. Right-click on the header of the form and select the item Constructor.
4. Now right-click in the data area and select Properties... The properties window discussed in the previous sections will open.
5. In the properties window go to the Layoutand for property Striping background colorspecify a color similar to the background color.
Form data can be printed out by interleaving the color of the data area so that you can easily see where the data area of \u200b\u200banother record begins. Another method that can be used is to output data for each record from a new page.
1. Right-click in the annotation area and select Properties... The properties window will open.
2. In the properties window go to the tab Layoutand for property Output modeindicate Screen only.
There are no annotations in our form, so there is no need to print the annotation area.
3. Go to the tab Constructorand from the group Control elementsselect tool Insert page break.
4. Specify the location for the page break by clicking on the bottom edge of the data area.
The form is now ready to print. You can use the preview function to check what the printed data will look like.
1. Open the main menu of the application by pressing the button Officein the upper left corner of the Access window.
2. From the menu, select Printing.
4. In a group Scaleselect a two-page layout on one sheet (Figure 3.25) to see how the first and second pages will look.
Figure: 3.25.Preview
5. Press the button Printing
in the tab Preview... A window will open Printing(fig. 3.26).
Figure: 3.26.Print window
6. In the field Nameselect your printer from the list of printers installed on your system. In field conditionthe printer is ready to print. If the condition is different from Ready, choose a different printer or troubleshoot.
7. If you want to print to a file, select the print to filegroup a printer.
8. In a group Printspecify the range of pages to print.
9. In a group Copiesspecify the number of copies.
10. Press the button Customization, after which a window will open Page settings(fig. 3.27).
Figure: 3.27.Page Setup window
11. In a group Fieldsspecify the sizes of the fields. The results of your changes are displayed in the preview window Sample.
For a split form, you can also specify which part to print.
12. Press the button OK.
If you want to check the properties of the printer, click Properties... The window that opens and its contents depend on the type of printer.
13. When ready to print, press the OK.
14. If you are printing to a file, a window will appear Print to file(fig. 3.28). Specify a file name and click OK.
Figure: 3.28.Print to file window
15. If you selected an existing printer for printing, a message about the printing process will appear immediately. Now you can any shape in Microsoft Access 2007. The next section will look at using a form as an interface for working with data.
Next chapter\u003e
Change the background color of a form and its elements The main parameter that determines the appearance of a form is its background color. Therefore, when choosing a background color, it is necessary to be guided by the purposes for which the developed form is intended and how it is planned to use it in the future. As a reminder, it is better to use less vivid colors for printed forms, since a colored background or a background with a pattern would require a lot of printer consumables. The background color of a section of a form or its element is determined by the value of the property Background color (Back Color). In a form created with the Form Wizard, the background of all its sections depends on the design style selected when it was created. For example, an autoformat was applied to the "Form_Employees" Standard (Standard), which sets the background color to light gray. To change the background color of a section of a form or its element:
Note that the background color of a section of a form in Access is set independently of the background color of other sections. Therefore, in order to change the color of all sections, you need to set a new color for each section separately. The background color of a section of a form does not affect the background color of controls within it. You can also choose a different background color and font color for each control. For control labels, the background color is usually set to transparent, that is, the background of the label is used as the part of the background of the form section that it occupies. By default, text boxes use a white background color, so the color of the text boxes (and the data they contain) contrasts with the background color of the form. You can set a transparent background color not only for labels, but also for controls such as text boxes and drop-down lists. To do this, select a control of one of the mentioned types, and then in the list Fill / background color select item Transparent (Transparent). Note that applying a transparent background color to the entire section of the form is not allowed. L task transparent background text box or drop-down list will have the following effect: in Shape mode, the color of the given control becomes transparent when that control is not active, that is, when the focus (insertion point) is on another element. When the insertion point is placed in this text box or drop-down list, it will take on the opaque background color that was previously assigned to it. An example of this display of fields can be seen in the Customer Orders form in the Northwind demo database (these are the Company Name and Country fields). The fact is that the value "transparent" does not actually correspond to a property of the element Background color (Back Color), and the property Background type (Back Style). The background type of an element can take one of two values: Usual (Normal) (when losing focus by an element does not change its color) or Transparent (Transparent). Hello! In this article, I will explain how to create a button in microsoft base Access. How to create a button in Microsoft Access databaseThe creation of buttons on a form is independent of which version of Access you have installed (2003, 2007, 2010, 2013, or 2016). In this article, I will show you 2 ways to create buttons on a form in the Acceess database: using a wizard and using a macro. How to do it?Step 1. Create the formIf you don't have a form, you need to create one. More details on how forms are created can be found HERE... Go to the "Create" tab, the "Form Wizard" item. Next, select a table or query, on the basis of which the form will be created. Next, select the required fields and click "Next". Choosing the appearance of the form. Set the name of the form and click "Finish". Open the form in design mode. How to create a button in Microsoft Access database will be described in the second step. Step 2. Create a button using the wizardOn the toolbar, select the "Button" item and place it on the form. The Button Wizard window appears. Here you need to select the required category and set a specific action. Select "Previous entry" and click "Next". Choose what is displayed on the button: text or image. We leave the picture by default and click "Next". Set the name of the button and click "Finish". Now let's create a button with text. Let's go to the master of buttons again, select "Next entry". Step 3. Creating a button using a macroOn the toolbar, select the "Button" item and place it on the form. The Button Wizard window appears. Click "Cancel". Double click on the created button to open the properties window. Go to the "Events" tab, item "Pressing the button". Press the button with three dots. We return to the "Table 1" form. Let's rename the button, set the label "Exit". Switch to the form mode and check how the "Exit" button works. The microsoft Access app should close. In this article, we have discussed how to create a button in the Microsoft Access database. If you need a ready-made Access database, then check out the list provided HERE. Attachments can be used to store multiple files (including different types) in one field. For example, in a business contact database, you can add one or more resumes and a photo to each contact record. Attachments also allow you to store data more efficiently. Earlier versions of Access used Object Linking and Embedding (OLE) technology to store images and documents. By default, OLE technology was used to create a raster equivalent of an image or document. These bitmap files can be too large - sometimes 10 times the size of the original file. When viewing an image or document from a database using OLE technology, the bitmap was displayed instead of the original file. With attachments, documents and other non-image files open in their respective programs, so you can find and edit these files directly in Access. In addition, OLE technology requires the use of programs called OLE servers. For example, if an Access database stores JPEG image files, each computer running the database must run a separate program registered as an OLE server for JPEG images. In contrast, Access saves attachments in their original formats without any supporting images, and no additional software is required to view images from the database. Attachments and Database Development RulesBy default, each field in a relational database contains only one piece of data. For example, if the address field contained several addresses, it would be difficult or even impossible to find the correct one. Therefore, at first glance, it seems that attachments violate database design rules, because you can add multiple files to a field, that is, several pieces of data. However, design rules are not violated, because when attaching files to a record, Access creates one or more system tables and uses them invisibly to normalize the data. You cannot view or work with these tables. For information on viewing other system tables, see the Navigation Pane Guide. For more information on database design, see Database Design Basics. Ways to use file attachmentsWhen working with attached files, the following rules must be observed. You can attach files only to databases created in Access that use the ACCDB file format. Attachments cannot be exchanged between Access databases (ACCDB) and older format databases (MDB). You need to create a field in the table and set the Attachment data type for it. You cannot change the data type after it is set to Attachment. It is possible to store several files in one record. For example, you can store images and files created with word processing programs and spreadsheets. You can attach data up to two gigabytes (the largest size in an Access database). Individual files cannot exceed 256 megabytes in size. To add, edit and manage attachments use the dialog box Investments... This dialog can be opened by double-clicking from the attachment field in the table. If you want to manage attachments from a form or view them from a report, you must add an attachment control to the form or report and associate that control with the desired attachment field in the table. By default, the attachment control processes images and displays program icons that correspond to other file types. Suppose you have a photo, resume, and Visio drawing attached to your post. As you navigate from one attachment to another, the control renders an image and displays program icons for Word and Visio documents. If you open a dialog box Investments from a spreadsheet or form, attachment files can be added, deleted, modified or saved. If you open a dialog box Investments from the report, you can only save attached files to a different location. Attachment files will be compressed by Access if they were not compressed originally. For example, JPEGs are compressed graphics programthat creates them, therefore access program does not compress them. If the program that you used to create the attachment is installed on your computer, the attachments can be opened and modified using that program. Attachments can be managed programmatically. The following sections provide instructions for adding and managing attachments. Adding an attachment field to a tableTo use attachments in Access, you must first add the attachment field to at least one of the database tables. There are two ways to add an attachment field to a table: in table mode or in design mode. This section describes both methods for adding a field. Adding an attachment field in table viewAdd an attachment field in design modeAttaching files directly to tablesAfter you add an attachment field to a table, you can attach files to the records in that table without creating a data entry form. You can also view attachments without using a form, but remember to view directly from tables using the programs that created the files or programs that support this type of file. For example, when opening a nested table word document Word starts and the document is viewed in that application, not Access. If Word is not installed on your computer, a dialog box prompts you to select a program to view the file. Adding an attachment to a tableOpening file attachments from a tableIn a table open in Datasheet view, double-click a cell in the attachment box. In the dialog box Investments double-click the file you want to open. Select the file and click the button Open. The file will open in its associated program - Excel files will open in Excel, and so on. Some image files can be opened with Windows Picture Viewer. If you want to go beyond viewing the image, you can right-click and choose Edit... This will launch the program with which this file was created, if it is installed on the computer. Saving changes in an attached fileUsing attachments with forms and reportsIf you need to use attachments with a form or report, use the attachment control. As you navigate from one database record to another, this control automatically displays the image files. If other file types are attached, such as documents or charts, the attachment control displays an icon that matches the file type. For example, if a presentation file is attached, a PowerPoint icon appears, and so on. This control allows you to see which files are attached and open a dialog box Investments... If this dialog is open from a form, attachments can be added, removed, modified, and saved. If you open it from a report, you can only save attachments to your hard drive or the network because the reports are read-only. The following sections provide instructions for adding a picture frame to a form or report, navigating between records, attaching files, and viewing attachments. Remember that moving between attachments is only possible if the record contains multiple attachments. Add an attachment control to a form or reportThis section describes how to add an attachment control to a form or report and bind it to the Attachment field in the appropriate table. The procedure for adding an attachment control is the same for a form and a report. The first step is to make sure that at least one database table has an attachment field. For more information on adding an attachment field, see the section above. Designing a form or report can be complex, so this section assumes that you already have a database with at least one table and one form or report. For information on creating tables, forms, and reports, see the following articles: Adding an attachment controlManaging attachments using a formAfter the attachment control is added to a form, attachment files can be added, modified, deleted, and saved directly from that form. If a record contains multiple attachments, you can scroll from one attachment file to another by scrolling (this is not possible with a table). Note: The user who created the form can make it read-only. In this case, the dialog box Investments can only be used to save attachments to your hard drive or network. File attachmentScrolling through attached filesNote: The steps in this section apply to forms and reports. Click the arrow to scroll through the attached files Back to (left) or Forward (to the right). To see the file names, click View attachmentswhich opens the dialog box Investments... The names of the attached files will be shown in the list Investments . Save attachments elsewhereThe steps in this section apply to tables, forms, and reports. Any of the files or all files attached to this entry, can be saved to your hard drive or network. Remember that if you choose to save all files, you cannot save individual files — you can only save all of them. To selectively save files, save them one at a time. First open the table, form or report that contains the attachments and then open the dialog box Investments. Opening a dialog box Investments from the table Open the table in table view and double-click the field that contains the attachment you want to save. Opening a dialog box Investments from a form or report Open the form or report that displays attachments. Navigate to the entry containing the attached files. Click the Image control that displays the attached files. The mini toolbar will open. Click the button View attachments. Saving a separate attachmentIn the dialog box Investments press the button Save as. A dialog box will open Save attachment. Use the list Foldersto navigate to the new file location and click Save. Save all attachmentsIn the dialog box Investments press the button Save all. A dialog box will open Saving attachments. Use the list Foldersto navigate to the new file location and click Save. Removing attachmentsThe steps in this section apply to tables and forms. Removing an attachmentDouble-click the attachment field in the table to open the dialog Investments. In a form (Layout View or Form View), navigate to the record that contains the attachment you want to remove, and on the mini toolbar, click View attachmentsto open a dialog box. In the dialog box Investments select the file you want to delete and click Delete. Using attachments without using a mouse or other pointing deviceThe next section describes how to use the keyboard to set focus in the Navigation Pane and open a table, form, or report that contains file attachments. Also, here are the step by step instructions by viewing attachments and opening a dialog box Investments. Opening a table, form, or report from the Navigation PanePress the F11 key. Note: If the Navigation Pane is closed, pressing F11 will open it and focus on that area. If the Navigation Pane is open, pressing F11 will close it. Press F11 again to open the Navigation Pane and move focus to it. Use the UP ARROW and DOWN ARROW keys to select a table, form, or report to open. Press Enter to open the selected object. When you open a table, the insertion point will be placed in the first field of that table. When you open a form or report, the focus will be on the first field. View attachments from tablesYou can use the arrow keys to move the cursor to the desired nesting field. Press the SPACEBAR. A dialog box will open Investments. To navigate between buttons in a dialog box, or from buttons to a list of attached files Investments use the TAB key. Note: OK Press the Tab key or the UP ARROW and DOWN ARROW keys, and then press Enter. Move between attachments by scrolling from a form or reportThese steps are only possible if you have a Microsoft Natural keyboard and the entry contains multiple attachments. Press the application key. A context menu will open. Please select Forward or Back to Repeat step 2 as needed to move to the next file attachment. Opening the Attachments dialog box from a form or reportThese steps are only possible with a Microsoft Natural keyboard. If necessary, use the Tab key to move focus to the attachment control. By default, Access highlights this control and its associated text box, if it exists. Press the application key. A context menu will open. Select item View attachments by using the Tab key or the arrow keys, and then press Enter. A dialog box will open Investments. Press the Tab key to navigate between buttons in a dialog box or from buttons to a list of attachments Attachments (change - double click). Posts can contain multiple attachments. If you want to select an attachment from a list of multiple files, use the Tab key to navigate to the file list, and then use the arrow keys to select the desired file. After that, press the Tab key to return to the buttons and select the desired action. By choosing required file and the button, press ENTER. When finished, select the button OK by using the Tab key or the arrow keys, and then press Enter. Attachment ReferenceThe following is a reference for attachments, including the supported image and document file formats, file naming conventions, and some information about how to attach files to recordings by programming. Supported image file formatsAccess is directly supported (that is, displayed using an attachment control without the need for additional software) the following graphic file formats: BMP (Windows Bitmap) ICON, ICO (icon) WMF (Windows Metafile) EMF (Enhanced Metafile) Supported document and other file formatsAs a rule, files created in any microsoft programs Office. In addition, you can attach log files (LOG), text files (TEXT, TXT), and compressed ZIP files. File naming conventionsAttached file names can contain any Unicode characters supported file system NTFS, which is used by Microsoft Windows NT (NTFS). In addition, filenames must comply with the following rules. Names cannot exceed 255 characters, including the filename extension. Names must not contain the following characters: question mark (?), Quotation marks ("), left or right slash (/ \\), angle brackets (< >), asterisk (*), pipe (|), colon (:), paragraph mark (¶). File types that Access compressesWhen you attach any of the following file types to your database, Access compresses the file if it was not originally compressed.
Blocked file formatsAccess blocks attachment of the following file types. The attachment of such files cannot be unblocked at this time. Attaching files to recordings by programmingAccess allows you to use the Object Model and Programming Interfaces to attach files to records programmatically using VBA (Visual Basic for Applications) code. For more information, see the articles "LoadFromFile" and "SaveToFile" on MSDN There was a problem of storing (loading, displaying) pictures (photos, etc.) in an Access database. At first glance, an experienced programmer ;-) nothing is easier - we store pictures in a table field with a type, and display them on forms using a control Attached object frame, well, or if required Unbound Object Frame (Bound Object Frame)... But it was not there!; It turned out that if you write data directly (in Visual Basic code), for example, using the method AppendChunk, in a field with type OLE Object Field, then in the control Attached object frame the image just isn't displayed. It is displayed only if you load data into this field using the context menu of the field itself or the specified control by selecting right an OLE object type (something like Picture, Picture ...). Such flexibility and clever data processing did not suit me very well. A control with a beckoning type Image designed to work exclusively with static images: at the design stage (well, in general, and from Visual Basic code), you can specify a file on disk that will be displayed on the form. After examining the DB of examples - Northwind in the English version, Borey in Russian - and having scanned the Internet pretty much, it became clear that the lack of normal work with images in Access is a generally recognized fact. There are two options: 1. Storing images as files on disk, and paths to them in the database. Displaying on a form using a control Imageby assigning the path as a value to the property Picture. 2. Storing pictures in the database in the fields OLE Object Field... Similar display on the form using a control Image... In this case, the method is used to download the file AppendChunk, and to display a picture, the data is uploaded to a temporary file using the method Getchunk, the path to the resulting file is assigned to the property Picture control element. This method is given with an example. The disadvantage of the first method is that when moving the file storage directory, the paths to the files saved in the database must be correctly changed. The disadvantages of the second method - you need to figure out how to achieve the uniqueness of the name of the temporary file (since theoretically several users can work with the database "from the same place"), and direct work with files on the disk still slows down the work. And both of these methods are not suitable for use in Continuous Forms, but only in Single Form. Already inclined to the 2nd option, as more acceptable, a thought flashed - and not try to use the control Image not only for display, but also for converting data into the desired graphic format using the property PictureData object Image?! And it worked! No temporary files are needed (although, of course, for Tape form it still doesn't fit, but it's not critical either). So, the idea is that the file is loaded by assigning the path to it to the property Picture control element Image, and then reading data from the property PictureData - in this way we ensure that the data is saved in a format that Access is guaranteed to display. And the display of the picture is performed by reading data from the field with the type OLE Object Field and assigning them to the property PictureData control element. Example. Let in our table MyTable there is a field MyImage type OLE Object Field... On the form MyForm we need a control Image - MyPic... At the same time, in order to place this control on the form, it is necessary to select a picture, and then in the designer in the property Picture indicate (is absent) ((none)) - with brackets. Answer in the affirmative to the question about deleting the picture. The download can be done like this: Set dlgFile \u003d Application.FileDialog (msoFileDialogOpen) dlgFile.AllowMultiSelect \u003d False strFilePath \u003d Trim $ (dlgFile.SelectedItems (1)) MyPic.Picture \u003d strFilePath Set rs \u003d CurrentDB.OpenRecordset ("MyTable", dbOpenDynaset) rs.AddNew MyPic.Picture \u003d "" "clear the picture, if necessary
Recommended
|