Dear Mr. Prem
I think u have taken this code from some site (probably from microsoft site) and tried to modify it. The problems with ur code (zip file posted by u) & their solutions are as below:
1. First, u have used x, q & z as counters but in ur code used only z. Due to this it searches for jpg file named as name of student (student field in table student) for clicked / selected record in DataGrid. Since u have named jpg files based on accesscode, it doesn't find a corresponding jpg file & gives error.
2. To overcome this problem use separate pointers for TextBox & Image Control.
3. When u click 'Show Data' connection is opened. Now if u click Print or Finalised Print, it gives error since connection is already open. So put a check for it.
4. Similarly for rs also.
5. Rename / Copy some .jpg files based on entries in student field and u will get output.
6. Design ur code properly with a SQL query so that output is for selected record only.
7. In command1_Click event modify code as
-
'img = fldr & "\" & rs.Fields(rs(z).Value) & ".jpg"
-
to
-
img = fldr & "\" & rs(z).Value & ".jpg"
-
I think edit ur code as above & get the result.
Anytime can ask for further help.