[Access 2000] Images on Form

C

croy

I've been trying to get an Image Frame working, but am
having troubles.

The form is a single form. I'd like the picture for each
photo record to appear in the Image Frame as the user moves
thru the pictures.

My photo.mdb has a table for photo information, and that has
a field for "path".

I made another table just to hold a single record in a
single field for "Drive Letter".

My thought was... a user could start the db and the
starting form would ask them to pick a drive letter from the
cbo list. That gets stored in the table ok.

In the Current event, I've been trying to get the syntax
right for adding the drive letter to the path, but haven't
figured it out after many hours of "try this".

Can anyone help?

Thanks,
croy
 
D

David W. Fenton

I've been trying to get an Image Frame working, but am
having troubles.

Version of Access makes a really big difference here, as recent
versions have improved image controls.
 
A

Access Developer

croy said:
I've been trying to get an Image Frame
working, but am having troubles.

The form is a single form. I'd like the
picture for each photo record to appear
in the Image Frame as the user moves
thru the pictures.

My photo.mdb has a table for photo
information, and that has a field for "path".

I made another table just to hold a single record in a
single field for "Drive Letter".

My thought was... a user could start the db and the
starting form would ask them to pick a drive letter from the
cbo list. That gets stored in the table ok.

In the Current event, I've been trying to get the syntax
right for adding the drive letter to the path, but haven't
figured it out after many hours of "try this".

I'm a little confused as to what you want, but I think it boils down to
this:

1. You have a path stored as a string (example:
":/somefolder/somesubfolder/")
2. You will store a drive letter (example: "d")
3. You wish to prepend the drive letter to the path (and end up with
example "d:/somefolder/somesubfolder")

The following function will do that: pass it the path, and the drive letter.
Of course you can do this directly in your own VBA code. I tested in the
function for the minimum possible meaningful length of the path and for the
drive letter being exactly one -- I included no additional validity
checking, but you may wish to do so. Note: it doesn't matter to this
function whether the path includes filename and extension, or whether you
will append that later.

Function PrependDrive(strPath As String, strDrive As String) As String
If Len(strPath) > 1 And Len(strDrive) = 1 Then
PrependDrive = strDrive & strPath
Else
PrependDrive = "Invalid Input"
End If
End Function

and some executions from the Immediate Window:

? PrependDrive (":/some/file.ext","f")
f:/some/file.ext
? PrependDrive (":/","f")
f:/
? PrependDrive (":","r")
Invalid Input
? PrependDrive (":/some/other/","rx")
Invalid Input

But that seems to me to be far too simple an operation to be giving you
trouble.

If I have misunderstood what you need, please post back here and someone
(maybe even I) will likely be able to suggest a solution.
 
C

croy

I'm a little confused as to what you want, but I think it boils down to
this:

1. You have a path stored as a string (example:
":/somefolder/somesubfolder/")
2. You will store a drive letter (example: "d")
3. You wish to prepend the drive letter to the path (and end up with
example "d:/somefolder/somesubfolder")

The following function will do that: pass it the path, and the drive letter.
Of course you can do this directly in your own VBA code. I tested in the
function for the minimum possible meaningful length of the path and for the
drive letter being exactly one -- I included no additional validity
checking, but you may wish to do so. Note: it doesn't matter to this
function whether the path includes filename and extension, or whether you
will append that later.

Function PrependDrive(strPath As String, strDrive As String) As String
If Len(strPath) > 1 And Len(strDrive) = 1 Then
PrependDrive = strDrive & strPath
Else
PrependDrive = "Invalid Input"
End If
End Function

and some executions from the Immediate Window:

? PrependDrive (":/some/file.ext","f")
f:/some/file.ext
? PrependDrive (":/","f")
f:/
? PrependDrive (":","r")
Invalid Input
? PrependDrive (":/some/other/","rx")
Invalid Input

But that seems to me to be far too simple an operation to be giving you
trouble.

If I have misunderstood what you need, please post back here and someone
(maybe even I) will likely be able to suggest a solution.

--
Larry Linson, Microsoft Office Access MVP
Co-author: "Microsoft Access Small Business Solutions", published by Wiley
Access newsgroup support is alive and well in USENET
comp.databases.ms-access

Thanks for your reply.

It sounds like you understand my need correctly. But your
approach is different than what I was trying to do.

I was trying to put code like this into the form's Current
event:

Dim PathInfo As String
PathInfo = [tblDriveLtr].[DriveLtr] & Me![PhotoPath]

Me![ImageFrame].Picture = Me![txtFilePath]

Now you probably get a better picture of where my skill
level falls.... ;-l
 
C

croy

I'm a little confused as to what you want, but I think it boils down to
this:

1. You have a path stored as a string (example:
":/somefolder/somesubfolder/")
2. You will store a drive letter (example: "d")
3. You wish to prepend the drive letter to the path (and end up with
example "d:/somefolder/somesubfolder")

The following function will do that: pass it the path, and the drive letter.
Of course you can do this directly in your own VBA code. I tested in the
function for the minimum possible meaningful length of the path and for the
drive letter being exactly one -- I included no additional validity
checking, but you may wish to do so. Note: it doesn't matter to this
function whether the path includes filename and extension, or whether you
will append that later.

Function PrependDrive(strPath As String, strDrive As String) As String
If Len(strPath) > 1 And Len(strDrive) = 1 Then
PrependDrive = strDrive & strPath
Else
PrependDrive = "Invalid Input"
End If
End Function

and some executions from the Immediate Window:

? PrependDrive (":/some/file.ext","f")
f:/some/file.ext
? PrependDrive (":/","f")
f:/
? PrependDrive (":","r")
Invalid Input
? PrependDrive (":/some/other/","rx")
Invalid Input

But that seems to me to be far too simple an operation to be giving you
trouble.

If I have misunderstood what you need, please post back here and someone
(maybe even I) will likely be able to suggest a solution.

--
Larry Linson, Microsoft Office Access MVP
Co-author: "Microsoft Access Small Business Solutions", published by Wiley
Access newsgroup support is alive and well in USENET
comp.databases.ms-access

Thanks for your reply.

It sounds like you understand my need correctly. But your
approach is different than what I was trying to do.

I was trying to put code like this into the form's Current
event:

Dim PathInfo As String
PathInfo = [tblDriveLtr].[DriveLtr] & Me![PhotoPath]

Me![ImageFrame].Picture = Me![txtFilePath]

Now you probably get a better picture of where my skill
level falls.... ;-l

Woops!

That should have been:

Dim PathInfo As String
PathInfo = [tblDriveLtr].[DriveLtr] & Me![PhotoPath]

Me![ImageFrame].Picture = PathInfo
 
A

Access Developer

That is not the correct way to access a field in a table in Access VBA code.

You can use DLookup or open a Recordset on the table. Even better, you can
access the single record of the single field of the table in your startup
code and save the drive letter.

If you store it in a Public Variable, it may be lost in case an error
occurs, so you may want to create a Property into which to store it, or just
look it up each time you use it, or retrieve it with a DLookup only if the
Public Variable is empty.

My guess is that using the DLookup in your VBA statement will not noticeably
deteriorate performance, and it would be the simplest approach. I think
there is good Help on DLookup in all versions of Access, but if you have
problems, keep posting.

--
Larry Linson, Microsoft Office Access MVP
Co-author: "Microsoft Access Small Business Solutions", published by Wiley
Access newsgroup support is alive and well in USENET
comp.databases.ms-access


croy said:
I've been trying to get an Image Frame
working, but am having troubles.

The form is a single form. I'd like the
picture for each photo record to appear
in the Image Frame as the user moves
thru the pictures.

My photo.mdb has a table for photo
information, and that has a field for "path".

I made another table just to hold a single record in a
single field for "Drive Letter".

My thought was... a user could start the db and the
starting form would ask them to pick a drive letter from the
cbo list. That gets stored in the table ok.

In the Current event, I've been trying to get the syntax
right for adding the drive letter to the path, but haven't
figured it out after many hours of "try this".

I'm a little confused as to what you want, but I think it boils down to
this:

1. You have a path stored as a string (example:
":/somefolder/somesubfolder/")
2. You will store a drive letter (example: "d")
3. You wish to prepend the drive letter to the path (and end up with
example "d:/somefolder/somesubfolder")

The following function will do that: pass it the path, and the drive
letter.
Of course you can do this directly in your own VBA code. I tested in the
function for the minimum possible meaningful length of the path and for
the
drive letter being exactly one -- I included no additional validity
checking, but you may wish to do so. Note: it doesn't matter to this
function whether the path includes filename and extension, or whether you
will append that later.

Function PrependDrive(strPath As String, strDrive As String) As String
If Len(strPath) > 1 And Len(strDrive) = 1 Then
PrependDrive = strDrive & strPath
Else
PrependDrive = "Invalid Input"
End If
End Function

and some executions from the Immediate Window:

? PrependDrive (":/some/file.ext","f")
f:/some/file.ext
? PrependDrive (":/","f")
f:/
? PrependDrive (":","r")
Invalid Input
? PrependDrive (":/some/other/","rx")
Invalid Input

But that seems to me to be far too simple an operation to be giving you
trouble.

If I have misunderstood what you need, please post back here and someone
(maybe even I) will likely be able to suggest a solution.

--
Larry Linson, Microsoft Office Access MVP
Co-author: "Microsoft Access Small Business Solutions", published by
Wiley
Access newsgroup support is alive and well in USENET
comp.databases.ms-access

Thanks for your reply.

It sounds like you understand my need correctly. But your
approach is different than what I was trying to do.

I was trying to put code like this into the form's Current
event:

Dim PathInfo As String
PathInfo = [tblDriveLtr].[DriveLtr] & Me![PhotoPath]

Me![ImageFrame].Picture = Me![txtFilePath]

Now you probably get a better picture of where my skill
level falls.... ;-l

Woops!

That should have been:

Dim PathInfo As String
PathInfo = [tblDriveLtr].[DriveLtr] & Me![PhotoPath]

Me![ImageFrame].Picture = PathInfo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top