ledgerr.rob
Registered User.
- Local time
- Today, 04:29
- Joined
- Jun 3, 2012
- Messages
- 68
Windows vista
access 2007
I've hitting a wall here. I'm populating a report with a query which pulls criteria from a form. When the 'run' button is pressed it opens the report, running the query, to filter the data. What i'm attempting (and it works if there is data present).
The data is text, which is a filename, which populates an image control. Most of my records have an image present but for the ones that don't I think I need to turn the image control's picture property to 'blank'.
I'm just now encountering problems with the records with no pictures so when i came up with this it worked with my tests which at that time only had images present....Sorry for the longwindedness...
I have two problems.
1) When I run the code as below i get Run-Time Error 2185; you can't reference a property or method for a control unless the control has the focus.
2) when i try to set the focus on the picture control in the report to see if there is text/value present i get runtime error 2478; database doesn't allow you to use this method in the current view.
I assume this is talking about me opening the report in acViewPreview mode but i thought i needed to do this so the images are displayed in the image control.
I know this is a long post, and i'm probably dancing around the issue but just don't seem to see the solution. With the reading i've done on this I've read that determining if text is present in a queried result should be done in the query...Should I be checking for the presence there? How would I do this?
Thanks
Rob
access 2007
I've hitting a wall here. I'm populating a report with a query which pulls criteria from a form. When the 'run' button is pressed it opens the report, running the query, to filter the data. What i'm attempting (and it works if there is data present).
The data is text, which is a filename, which populates an image control. Most of my records have an image present but for the ones that don't I think I need to turn the image control's picture property to 'blank'.
I'm just now encountering problems with the records with no pictures so when i came up with this it worked with my tests which at that time only had images present....Sorry for the longwindedness...
I have two problems.
1) When I run the code as below i get Run-Time Error 2185; you can't reference a property or method for a control unless the control has the focus.
2) when i try to set the focus on the picture control in the report to see if there is text/value present i get runtime error 2478; database doesn't allow you to use this method in the current view.
I assume this is talking about me opening the report in acViewPreview mode but i thought i needed to do this so the images are displayed in the image control.
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim strDBPath As String
Dim strRelativePath As String
Dim strPath As String
'rptOriginalOwnerCategoryItem!Picture.Text.SetFocus
[B]Me!Picture.SetFocus[B]
'Test to see if the record has a relative path stored
'if IsNull(Me!Picture.Text)=True Then
'If IsNull(Me!Picture)=True Then
[B]If Me!Picture.Text = "" Then[/B]
'If it does not (null) turn the picture value to nothing
Me.imgControl1.Picture = ""
Else
'If it does (not null) then turn the picture value to the full path
'store the relative path
'Me!Picture.SetFocus
strRelativePath = Me!Picture.Text
'store the path of the database
strDBPath = CurrentProject.path
'concatenate the DB path, the image folder, and the relative path and store to strPath
strPath = strDBPath & "\Images\" & strRelativePath
'set the picture value to strPath
Me!imgControl1.Picture = strPath
End If
End Sub
I know this is a long post, and i'm probably dancing around the issue but just don't seem to see the solution. With the reading i've done on this I've read that determining if text is present in a queried result should be done in the query...Should I be checking for the presence there? How would I do this?
Thanks
Rob