I have an MS-Access table that has a field containing a path to a .jpg file. I am trying to create a report that displays several fields from the table, and displays the actual graphic (photo of an inventory item), rather than the path to the graphic.
Yes, those worked fine for a form. I am able to take a value from a field in the record, and set "picture" property in the image control on a form. But I need to be able to get this to work on a report. I have tried the following:
Private sub Detail_Paint()
Me.Controls.Item("_Image").Picture = Me.Controls!main_photo.Value
End Sub
This code sets the photo source. Unfortunately, it sets the same photo for all records in the report. Help me Obi-wan Knobi. Your my only hope.
Related
I have taken over an MS Access database that was created by an employee that has moved on. It appears that he has created a form in the database by importing a paper form that is used within our company. What makes me believe that he imported a paper form is the exactness of Access form in relation to the paper form.
I am not sure how to ask query this using Google nor Bing. Can someone point me in the right direction on how to do this, please? I need to do the same thing with another paper form.
Yes, June7 is right, this is a handy technique.
Scan your paper document as JPG or PNG
Create a blank Access Form, and from the Design ribbon menu, choose "Insert Image" and select your newly created JPG or PNG scan
For the image object, check the properties window and make sure the "Sizing Mode" is set to Clip (and not Stretch or Zoom)
Now re-size the Image on your form so you can see everything correctly.
Now add Text boxes on top of the image, to create fillable text fields, exactly over the same place as the ones in the scanned image behind your text boxes.
You can then make a Table with the same field names, and update the Form to use this Table as it's Data Source on the Data Tab of the Form properties.
Once you have the form working perfectly nicely,
a handy time-staving step is File -> Save Object As -> change the Form dropdown to Report
Now you have created a Report that is printable using the same data table you created earlier (and write macro or VBA code make sure you print only one record at a time if that is the normal behaviour you expect)
I´m creating a form that displays the info of all of the employees, including their photo.
When in design view, I've tried using an image control and defining in its control source.
However, when I change to form view and navigate the employees records, their photo isn´t shown.
I've tried changing the field (where the photos are stored) data type to text, instead of hyperlink (as shown in this youtube video: https://www.youtube.com/watch?v=f5ZOOMrDjtU ) but the photos still do not appear.
The photos are stored as hyperlinks, that show the file path, and if i'm in datasheet view of the table, I can click on the employees photo hyperlink and it opens their photo.
Also, in access options, I have this picture property storage format selected: and the images are jpg files.
Does someone know how I can solve this issue? What could I have done wrong?
Thank you.
A true hyperlink in Access is made of 3 parts separated by # character.
display text # file name # any reference within the file
More info http://allenbrowne.com/casu-09.html
The hyperlink structure won't work in Image control ControlSource property and can't simply convert the hyperlink field to a text type as the resulting string will not be a valid file path. Either manually enter correct image file path or use string manipulation code to extract file path part from the hyperlink field and save to a text field (x represents fieldname):
Mid(Left(x,InStrRev(x,"#")-1),Instr(x,"#")+1)
On second thought, that expression could be in the ControlSource property so the hyperlink field could be retained as is and a text field not needed.
More info on expressions in ControlSource property: Access Form: `abc.Picture="xyz.jpg"` makes listbox & textboxes "blink" once
I have an Access 2010 form with a subform that is displayed in datasheet view. The users want to be able to select and copy the rows from the subform and when they paste into Excel they want the table header to be the value from the main form. Currently it just uses the name of the subform. Is there a way to set this to something else?
Here is what currently shows up in Excel after I paste the copied grid. What I want to have displayed instead of fsubFYTBSummary is a field from the parent record of the form that invoked the subfrom. Is there a way to set this?
There is no way. The copied name is the name of the source object, not the subform control (that would be changeable).
Actually I'm surprised you see this name in Excel. I only see it when pasting a grid to Word or an Email, where the HTML clipboard format is used. The name is the table caption.
You can use http://freeclipboardviewer.com/ (portable) to see the various formats of clipboard contents.
I have a table in Access 2010 called Table1. Column NCBI contains hyperlinks to webpages. I would like to display each hyperlink as a button in each cell and the caption for that button to be the field value from the same row one column to the left, the column Gene.
Does anyone know how to accomplish this?
First you must have the table containing the website information. In my example I have a table called Websites. In the table there is two fields: URL which contains the direct URL such as http://google.com and WEBSITE_NAME which is simply the name of the website "Google".
Create the form however you would like it to look using whatever Default View that you would like, however make sure that the Record Source is set to the table containing the website name's and URL's. In my test one I used Datasheet.
On that form make sure at least the WEBSITE_NAME field is showing on form in a textbox, in mine I called it txtWEBSITE_NAME. There is a property that belongs to the txtWEBSITE textbox called Display as Hyperlink set that to "Screen Only".
Then go to the events tab of the txtWEBSITE, go to the On Click event and click the three dots and add this code to the sub procedure:
Private Sub txtWEBSITE_Click()
If Nz(Me.URL, "") <> "" Then
Application.FollowHyperlink Me.URL, , True
End If
End Sub
The Me.URL basically just says to use the URL that corresponds to the Website that was clicked. The Nz() function basically just checks to make sure that there is actually a URL that belongs to the website that was clicked.
You can add in your own error handling or validation checks but this is the barebones system that you can use to do what you were looking for.
I have a report in MS Access with 4 image controls. In the format event of the detail section I have code that sets the picture property based on the values of fields in DAO.recordset. Below is an example of my code.
For i = 0 To 3
If Not rs.EOF Then
Me.Controls("img" & i).Picture = blobGet(rs!phBlobId)
rs.MoveNext
Else
Me.Controls("img" & i).Picture = ""
End If
Next i
Basically the rs!phBlobId field is a file name. The blobGet function returns the full path to the picture which then sets the picture property of the correct control in the detail section of my report.
I'm not sure all of the causes but under certain circumstances the pictures will not show up in the controls. I have a similar set up on a form and have no trouble at all there, I only have the issue when on a report.
One thing that seems to possibly be the cause is the size of the picture. If I insert a large picture (say over 5 megs) it sometimes won't show up. With different combination of pictures different ones show up.
I am open to both solutions to my problem as described above or to alternative ideas how to show these pictures on the report. One absolute requirement is that the pictures be set with VBA as the exact arrangement of the pictures varies based on an unrelated variable.
The solution I came up with was to simply resize the images using imageMagick. This actually provides me with a couple advantages. Not the least of which is a substantial performance improvement since I am dealing with smaller images.