Can't link text box (1 Viewer)

Crash_Pie

Registered User.
Local time
Today, 11:53
Joined
Feb 15, 2007
Messages
36
Hi, I'm probably overlooking something real simple, but it's been a while since I played with access.

I have a form (frmInputData) based on a table (tblStudComments), which contains comments about student performance. The form also contains combo boxes, the second combo box list is based on the content of the first. (1st Combo is the course number, 2nd combo is the student name).

I wish to display the photos of the students as I enter data about them into this form (frmInputData). The photos are linked, and the relative paths are already stored in a different table which contains the students details. I have already stored the photo's in the tblStudNames table using a different form (where I enter the initial data on the students and it works fine).

I have followed all of the numerous examples of using a text box on the form to display the path, then use an image frame to show the photo (via some code), however I believe the problem is I cant get the text box (for the photo path) control source to point to the "photopath" field in the student details table, because this isn't the table the form is based on.

How can I fix this?
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:53
Joined
Jul 2, 2005
Messages
13,825
Can't you join the student details table to your current query with the StudentID maybe?
 

Crash_Pie

Registered User.
Local time
Today, 11:53
Joined
Feb 15, 2007
Messages
36
Ok this is getting frustrating. I have done as suggested and referenced the form to a query containing the fields I want, and yes, now the field can be linked to the text box.

I can see the "file locations" in the text box, but now my image frame won't display the photo's. I've tried the various code examples on this forum but to no avail. For some reason it's not picking the file location out of the text box. I have check and the image frame is set to visible.

Any further assistance greatly appreciated.
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:53
Joined
Jul 2, 2005
Messages
13,825
What code are you using to display the photo? Are you using a fully qualified path name?
 

Crash_Pie

Registered User.
Local time
Today, 11:53
Joined
Feb 15, 2007
Messages
36
Hi thanks for helping.

I've attached part of the database for you to look at. You'll need to adjust the path in the table to find the photo's included in the zip file.

The form giving grief is "frmInputData".

Thanks
 

Attachments

  • Database.zip
    121.9 KB · Views: 111

RuralGuy

AWF VIP
Local time
Yesterday, 17:53
Joined
Jul 2, 2005
Messages
13,825
Just unzip this in its own folder and open the db without the shift key and cycle through the 6 records and see if that is what you wanted. It should find the photos on its own. I changed the Photo field and the Current Event of the form.
 

Attachments

  • CrashPieDB.zip
    85.2 KB · Views: 118

Crash_Pie

Registered User.
Local time
Today, 11:53
Joined
Feb 15, 2007
Messages
36
Hey that's great thanks, at least I can see it can be done!

But, I've seen a couple of things in your sample file:

1. I now have to use the record buttons at the bottom of the form (weren't there previously) to see the records. Because we have lots of students I'd prefer to still use the two combo box's for course selection followed by student selection.

2. I noticed you changed the path to the photo's to be in the same folder as the database. I should have explained that this will not be the case (sorry my sample db was misleading with the accompanying photos). How do I modify the current event to find the path of the photo's if they are not on the same drive or in same folder? It's quite likely with the way our system is set up at work that the database and the photo's will not be co-located.

I hope I'm not asking too much, thank you very much for all the help so far.
 
Last edited:

RuralGuy

AWF VIP
Local time
Yesterday, 17:53
Joined
Jul 2, 2005
Messages
13,825
I just modified the Photo field so this sample would work. If you store the complete path in the Photo field then you don't need to use the CurrentProject.Path that I used. You can just use the value right out of the Photo field like you had it before. I enabled the Nav buttons just so it was easier for you to see that it works.
 

Crash_Pie

Registered User.
Local time
Today, 11:53
Joined
Feb 15, 2007
Messages
36
Hi again

What exactly did you change with the photo field? Because as you can see from my original sample, I was using full path names. I can't actually see what you've changed to make it all work? (I do see your code in the OnCurrentEvent). I have noticed that the second combo box "student name" no longer works in your sample, and if I turn on the qrycomboboxudate in the afterevent on the first combobox I now get another error.

It's all a bit weird.
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:53
Joined
Jul 2, 2005
Messages
13,825
I changed the Photo field to only have the FileName.Ext rather than the entire path and FileName.Ext. I'll go back and look at the db and see if I can duplicate what you are seeing. Again, my first shot was just tossed together to show you that it can work.
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:53
Joined
Jul 2, 2005
Messages
13,825
Is this db more what you had in mind?
 

Attachments

  • CrashPieDB.zip
    87.2 KB · Views: 114

Crash_Pie

Registered User.
Local time
Today, 11:53
Joined
Feb 15, 2007
Messages
36
I've had a quick look and yes thanks that looks like what I'm after. I'll copy bit's across to my proper database and see if it works with "full" paths for the photos. I'll let you know how I go.

Thanks very much for your help and the awesome response times.
 

Crash_Pie

Registered User.
Local time
Today, 11:53
Joined
Feb 15, 2007
Messages
36
Well RG, I think I've been a nutter all along!?

Thanks to your latest sample DB I got the photo's to display, but then I noticed that some "old" data was appearing in the other fields. I also saw that you had set the two first combo's to "" in the OnLoad event, and then the penny dropped.

Because the form properties for the Data Entry was set to "Yes" the photo wouldn't display. When set to "No" the photo does display because it is "old" data. (How dumb am I?!)

So now I have a whole new problem. I need the form to open to a new record every time. Obviously when I set the Data Entry back to Yes I get a blank form, but no photo, and to get around that I've tried setting all fields using the same "" code in the OnLoad, and the Data Entry to No. This doesn't work, because after entering data in the second combobox the other fields somehow retrieve "old" data again.

Is it possible to have a subform which will display the photo using "old" data, with the main form set to Data Entry Yes?

The whole idea of the form was to enter new data (comments), with the students photo displaying to confirm you are making comments about the right person. I don't want to edit existing data with this form.

Can this be done?
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:53
Joined
Jul 2, 2005
Messages
13,825
You do *not* want a new record! You want to edit a field on an existing record. Set *all* of the controls you do not want the user to modify to Enabled = No and Locked = Yes. Then the user can *only* edit the field you want.
 

Crash_Pie

Registered User.
Local time
Today, 11:53
Joined
Feb 15, 2007
Messages
36
I don't quite follow you there?

I don't want to edit any fields in this form. I want the user to select a course, and then the student on that course. The photo of the student should then display for confirmation you've selected the right person. After that all other fields should be new entrys.

This all worked fine before I tried to get smart and put a photo on the system.

I can't set the photo property to "Enabled = No and Locked = Yes", because those options aren't there (I think because it is doesn't actually contain any data)

Am I making sense?
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:53
Joined
Jul 2, 2005
Messages
13,825
How about just doing a DLookUp() to fill in the picture?
 

Crash_Pie

Registered User.
Local time
Today, 11:53
Joined
Feb 15, 2007
Messages
36
Thanks for all your help RG.

I've tried the DLookup and have managed to get the photo's to display when I want.

Now I'll just experiment with some error code for if there is no valid photo path (or photo). Hopefully there is something in this forum I can use as an example.

So once again thanks for your patience and assistance.
 

RuralGuy

AWF VIP
Local time
Yesterday, 17:53
Joined
Jul 2, 2005
Messages
13,825
You're welcome. I'm always glad to give people a gentle nudge in the right direction.
 

Users who are viewing this thread

Top Bottom