Filtered records

  • Thread starter Thread starter OveB
  • Start date Start date
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
 
Ove

If you already have a table in which you keep the "path" to the images,
another thought would be to do a query for ONLY those records with a
non-zero-length path.
 
Jeff,
The table does not contain any path field. The images are "looked up" with
the code. This means that I only have to put the image into the folder and
that is all./Ove


Jeff Boyce said:
Ove

If you already have a table in which you keep the "path" to the images,
another thought would be to do a query for ONLY those records with a
non-zero-length path.

--
Good luck

Jeff Boyce
<Access MVP>

OveB said:
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
 
I'm not sure I understand. There must be something you are storing in your
table to help you find an image -- what pieces are you using to construct
the path to where the image lives? Doesn't your code mention a "Me!NR" --
where is that located?

Jeff Boyce
<Access MVP>

OveB said:
Jeff,
The table does not contain any path field. The images are "looked up" with
the code. This means that I only have to put the image into the folder and
that is all./Ove


Jeff Boyce said:
Ove

If you already have a table in which you keep the "path" to the images,
another thought would be to do a query for ONLY those records with a
non-zero-length path.

--
Good luck

Jeff Boyce
<Access MVP>

OveB said:
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
 
Jeff,
I learned this from another MVP a couple of years ago.
The NR is a field in the main table (called Saker (=Items)), where all the
properties are stored, and contains a unique item number (there are around
8000 items). The code forms a path from each number and if no image is found
in the given folder the path is not valid and the result will be blank ("")
and the name of my zero image is put in. This is as I have understood the
procedure, it was never explained in words before. My thought behind the my
original issue 1. was to use the content of Place to tell the program not to
print that record instead of printing my zero image as is done now.

I have a similar code for showing the images in the form where it is in the
current event of the form. This also works well.
Regards and thanks for your efforts
Ove





Jeff Boyce said:
I'm not sure I understand. There must be something you are storing in
your
table to help you find an image -- what pieces are you using to construct
the path to where the image lives? Doesn't your code mention a "Me!NR" --
where is that located?

Jeff Boyce
<Access MVP>

OveB said:
Jeff,
The table does not contain any path field. The images are "looked up"
with
the code. This means that I only have to put the image into the folder
and
that is all./Ove


Jeff Boyce said:
Ove

If you already have a table in which you keep the "path" to the images,
another thought would be to do a query for ONLY those records with a
non-zero-length path.

--
Good luck

Jeff Boyce
<Access MVP>

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
 
So, it appears I assumed too much. Your database doesn't actually have an
entry ONLY if there's an image, it has a "place holder" ID, just in case
there is an image at that location.

I suppose another approach would be to first test to see if a file exists at
that location (?perhaps using a "directory"-related command -- sorry, little
experience here)...

Good luck!

Jeff Boyce
<Access MVP>

OveB said:
Jeff,
I learned this from another MVP a couple of years ago.
The NR is a field in the main table (called Saker (=Items)), where all the
properties are stored, and contains a unique item number (there are around
8000 items). The code forms a path from each number and if no image is found
in the given folder the path is not valid and the result will be blank ("")
and the name of my zero image is put in. This is as I have understood the
procedure, it was never explained in words before. My thought behind the my
original issue 1. was to use the content of Place to tell the program not to
print that record instead of printing my zero image as is done now.

I have a similar code for showing the images in the form where it is in the
current event of the form. This also works well.
Regards and thanks for your efforts
Ove





Jeff Boyce said:
I'm not sure I understand. There must be something you are storing in
your
table to help you find an image -- what pieces are you using to construct
the path to where the image lives? Doesn't your code mention a "Me!NR" --
where is that located?

Jeff Boyce
<Access MVP>

OveB said:
Jeff,
The table does not contain any path field. The images are "looked up"
with
the code. This means that I only have to put the image into the folder
and
that is all./Ove


"Jeff Boyce" <[email protected]_HYPHEN_TO_END> skrev i
meddelandet Ove

If you already have a table in which you keep the "path" to the images,
another thought would be to do a query for ONLY those records with a
non-zero-length path.

--
Good luck

Jeff Boyce
<Access MVP>

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
 
Back
Top