Hello,
I don't completely understand the working of these functions, but it's been suggested that these will give me what I need.
I have a database that pulls in image files (stores the absolute path in database). The image shows up in my subform. The file name is displayed in a form control called 'image description'. The problem is it displays the entire link, such as c:\imageCats\GizmotheCat.jpg (absolute path)....
End user cah 'browse' to any folder they may have stored pictures to retrieve an image. So the absolute path will change with each end-user. I don't want to hardcode a specific path. However, I do need the absolute path to an image stored and only display in the control a name, i.e. GizmotheCat.
I'm looking for real working example code for StrReverse (InStr), so I can somehow reverse the string, cut off the 'GizmotheCat.jpg and display only the GizmotheCat in this control. I also like the .jpg to go into another control box. I've received some examples, but can't get them working in my form.
Does anyone have something like this? Thanks in advance.
Rosie
7 3734
This function should do what you want. -
-
Function getFName(path As String) As String
-
Dim fName As String
-
Dim pos1 As Integer
-
Dim pos2 As Integer
-
Dim tmpPos As Integer
-
pos1 = 1
-
Do Until (InStr(pos1, path, "\") = 0)
-
tmpPos = InStr(pos1, path, "\")
-
pos1 = tmpPos + 1
-
Loop
-
pos2 = InStr(path, ".") - pos1
-
fName = Mid(path, pos1, pos2)
-
getFName = fName
-
-
End Function
-
Hello,
I don't completely understand the working of these functions, but it's been suggested that these will give me what I need.
I have a database that pulls in image files (stores the absolute path in database). The image shows up in my subform. The file name is displayed in a form control called 'image description'. The problem is it displays the entire link, such as c:\imageCats\GizmotheCat.jpg (absolute path)....
End user cah 'browse' to any folder they may have stored pictures to retrieve an image. So the absolute path will change with each end-user. I don't want to hardcode a specific path. However, I do need the absolute path to an image stored and only display in the control a name, i.e. GizmotheCat.
I'm looking for real working example code for StrReverse (InStr), so I can somehow reverse the string, cut off the 'GizmotheCat.jpg and display only the GizmotheCat in this control. I also like the .jpg to go into another control box. I've received some examples, but can't get them working in my form.
Does anyone have something like this? Thanks in advance.
Rosie
Rosie, Rosie, I thought we covered all this?
Hello,
I don't completely understand the working of these functions, but it's been suggested that these will give me what I need.
I have a database that pulls in image files (stores the absolute path in database). The image shows up in my subform. The file name is displayed in a form control called 'image description'. The problem is it displays the entire link, such as c:\imageCats\GizmotheCat.jpg (absolute path)....
End user cah 'browse' to any folder they may have stored pictures to retrieve an image. So the absolute path will change with each end-user. I don't want to hardcode a specific path. However, I do need the absolute path to an image stored and only display in the control a name, i.e. GizmotheCat.
I'm looking for real working example code for StrReverse (InStr), so I can somehow reverse the string, cut off the 'GizmotheCat.jpg and display only the GizmotheCat in this control. I also like the .jpg to go into another control box. I've received some examples, but can't get them working in my form.
Does anyone have something like this? Thanks in advance.
Rosie
Hi, Rosie.
Now I've got how irrelevant was my advice to use custom class. Remember? ;)
Here I'm suggesting you the following solution.
1. Put the code below to a public module. -
-
Public Function ExtractFileExt(varFullPath As Variant) As String
-
If IsNull(varFullPath) Then Exit Function
-
ExtractFileExt = StrReverse(Left(StrReverse(varFullPath), _
-
InStr(1, StrReverse(varFullPath), ".")))
-
End Function
-
-
Public Function ExtractFileName(varFullPath As Variant) As String
-
If IsNull(varFullPath) Then Exit Function
-
ExtractFileName = StrReverse(Mid(StrReverse(varFullPath), _
-
InStr(1, StrReverse(varFullPath), ".") + 1, _
-
InStr(1, StrReverse(varFullPath), "\") - _
-
InStr(1, StrReverse(varFullPath), ".") - 1))
-
End Function
-
-
Specially for you 4 "Instr"s and 8 "StrReverse"s. ;) The following assumes your form field with picture full path has name "txtPictureFullPath".
2. Set DataSource of the field displaying file extension to
=ExtractFileExt([txtPictureFullPath])
3. Set DataSource of the field displaying file name to
=ExtractFileName([txtPictureFullPath])
Hope that this will help you.
Goooooogluck.
Rosie, Rosie, I thought we covered all this?
We did and it's working fine...I posted this days ago and I don't know how to close the discussion other than to tell everyone, that I've got a working solution.
Thanks ADezii. take care
Rosie
Hi, Rosie.
Now I've got how irrelevant was my advice to use custom class. Remember? ;)
Here I'm suggesting you the following solution.
1. Put the code below to a public module. -
-
Public Function ExtractFileExt(varFullPath As Variant) As String
-
If IsNull(varFullPath) Then Exit Function
-
ExtractFileExt = StrReverse(Left(StrReverse(varFullPath), _
-
InStr(1, StrReverse(varFullPath), ".")))
-
End Function
-
-
Public Function ExtractFileName(varFullPath As Variant) As String
-
If IsNull(varFullPath) Then Exit Function
-
ExtractFileName = StrReverse(Mid(StrReverse(varFullPath), _
-
InStr(1, StrReverse(varFullPath), ".") + 1, _
-
InStr(1, StrReverse(varFullPath), "\") - _
-
InStr(1, StrReverse(varFullPath), ".") - 1))
-
End Function
-
-
Specially for you 4 "Instr"s and 8 "StrReverse"s. ;) The following assumes your form field with picture full path has name "txtPictureFullPath".
2. Set DataSource of the field displaying file extension to
=ExtractFileExt([txtPictureFullPath])
3. Set DataSource of the field displaying file name to
=ExtractFileName([txtPictureFullPath])
Hope that this will help you.
Goooooogluck.
Thanks so much FishVal....I will test this out and if it works, I'll use it in a future project. ADezii gave me one that I've got working. so thanks again. I'll post back to let you know if it also fixed my issue. thanks and take care.
NeoPa 32,556
Expert Mod 16PB
Rosie, In future, simply reply to the thread that you have a solution. That will let everyone know that further solutions are not required. I will not close the thread, as it seems obvious now that no further advice is required anyway.
Thanks to our expert MissingLinq for bringing this to my attention.
We did and it's working fine...I posted this days ago and I don't know how to close the discussion other than to tell everyone, that I've got a working solution.
Thanks ADezii. take care
Rosie
It was a pleasure working with you.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Chris Michael |
last post by:
Hello everybody,
Newbie here. I've been working on this for the last two days and I can't
figure out where this problem is. I think it's something so obvious, but I
can't see it!
OK, firstly...
|
by: Danny |
last post by:
I am trying to do a regular expression to search for
a url
so anything that has http:\\www.hellothere.com
but may not have the http:\\
and may not have the www
and may not have http:\\www
and...
|
by: Theresa Hancock via AccessMonster.com |
last post by:
I have an Excel table I need to import into Access. The name is entered into one field "Name". I'd like to have two fields in Access, FirstName and LastName. How do I do this.
--
Message posted...
|
by: google |
last post by:
I'm trying to implement something that would speed up data entry. I'd
like to be able to take a string, and increment ONLY the right-most
numerical characters by one. The type structure of the...
|
by: John Cobb |
last post by:
I've removed the Microsoft.VisualBasic import from my VB.Net project and am
in the process of replacing the vb6 compatible calls with native .Net i.e.
system.datetime.now instead of Now, variable...
|
by: jimmy |
last post by:
I am working on a project which tracks 'bad' words in IE and im using a
For loop to check for an array of words in he address bar. I have
included the broken code below. Any pointers on why it isnt...
|
by: Rex |
last post by:
Hi I want to write a procedure which takes in a string of names
seperated by a whitespace and puts commas at each whitespace the last
name however, should have "and" before it.
Let me explain...
|
by: talktozee |
last post by:
Hello, everyone!
Here's are the basics:
1. The query looks at all positions that are active and haven't been filled.
2. It then has to look at every single position and determine three...
|
by: thesinnerishere |
last post by:
i have created a program(link-generator) which is static in nature(it works correctly) meaning that this program must find the symbol { } first for it to operate properly.how can i make it dynamic so...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |