O
OveB
I have a report where the objects in a small local Swedish museum are listed
with
properties and images but only half of the objects have so far been
photographed. For a new purpose I would like to create a new report only
showing the objects that have a picture available. The images appear in a
subfolder "Images" and their names are built up with 3 letters "soh"
followed by four digits from the object # (NR), thus soh????.jpg.
I have also created a picture "soh0000.jpg" that only tells "No picture
fed". In the report the images are placed in an unbound Image box , named
PictA. The
following code is used with success in the present report:
Private Sub Detalj_Print(Cancel As Integer, PrintCount As Integer)
Dim Place As String
Dim NRPadded As String
NRPadded = Right("000" & CStr(Me!NR), 4)
Place = "C:\Mus\Images\soh" & NRPadded & ".jpg"
If Dir(Place) = "" Then Place = "C:\Mus\Images\soh0000.jpg"
Me![PictA].Picture = Place
End Sub
To get the desired new report I have as a layman on Access thought of three
possibilities (are there more or better ones?):
1. Introduce a line next before the last one above, saying in principle:
If Place = "C:\Mus\Images\soh0000.jpg" Then Goto NextRecord ,,,
but I cannot find the correct expression
2. Create a filter somewhere to sort out those with an image but this seems
also difficult to accomplish. I have to use a table field?
3. Create a new table with a calculated field, telling Yes/no for an
existing or nonexísting image. I could then use this Yes/No in a query. But
it seems not possible to create a new table with a calculated field. Or?
As you understand I am not sufficiently experienced for any of these
possibilities and would very much appreciate any detailed help on designing
a code for one
of these.
I use AccXP.
Regards and thanks in advance
Ove
with
properties and images but only half of the objects have so far been
photographed. For a new purpose I would like to create a new report only
showing the objects that have a picture available. The images appear in a
subfolder "Images" and their names are built up with 3 letters "soh"
followed by four digits from the object # (NR), thus soh????.jpg.
I have also created a picture "soh0000.jpg" that only tells "No picture
fed". In the report the images are placed in an unbound Image box , named
PictA. The
following code is used with success in the present report:
Private Sub Detalj_Print(Cancel As Integer, PrintCount As Integer)
Dim Place As String
Dim NRPadded As String
NRPadded = Right("000" & CStr(Me!NR), 4)
Place = "C:\Mus\Images\soh" & NRPadded & ".jpg"
If Dir(Place) = "" Then Place = "C:\Mus\Images\soh0000.jpg"
Me![PictA].Picture = Place
End Sub
To get the desired new report I have as a layman on Access thought of three
possibilities (are there more or better ones?):
1. Introduce a line next before the last one above, saying in principle:
If Place = "C:\Mus\Images\soh0000.jpg" Then Goto NextRecord ,,,
but I cannot find the correct expression
2. Create a filter somewhere to sort out those with an image but this seems
also difficult to accomplish. I have to use a table field?
3. Create a new table with a calculated field, telling Yes/no for an
existing or nonexísting image. I could then use this Yes/No in a query. But
it seems not possible to create a new table with a calculated field. Or?
As you understand I am not sufficiently experienced for any of these
possibilities and would very much appreciate any detailed help on designing
a code for one
of these.
I use AccXP.
Regards and thanks in advance
Ove