473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to store only filename instead of entire path in a field in access 2007?

Hi,

I have a form named as "Add New Stock" and it has some controls.
There is control name as "Reference" along with "Browse folder" button. So user can select a file through this Browse button and the entire file path displays in "Reference" (Textbox) control.

Also this Reference control is bound field which is bounded to a field(type is Hyperlink) in table.

1. Now what i want is like, this Reference control should only show the "FILENAME" and NOT the entire path when user select any file through "Browse" button.
But at the same time, this filename should be clickable so that when user click on this Filename, file should get opened.

The idea is to make this control user friendly as we should show only Filename to him and not the entire path but he wants to open the file he can see it by clicking it.
The code on BrowseButton click event is below:


Expand|Select|Wrap|Line Numbers
  1.  Private Sub ButtonTraceRef_Click()
  2.  
  3.     ChDrive "M"
  4.     ChDir "M:\Certificates"
  5.  
  6.      Dim fDialog As Office.FileDialog
  7.      Dim varFile As Variant
  8.      Dim strSelectedFile As String
  9.      Dim CellText As String
  10.  
  11.        ' Clear listbox contents. '
  12.        Me.ComboTracabilityRef.RowSource = ""
  13.  
  14.        ' Set up the File Dialog. '
  15.        Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
  16.  
  17.        With fDialog
  18.  
  19.           ' Allow user to make multiple selections in dialog box '
  20.           .AllowMultiSelect = False
  21.  
  22.           ' Set the title of the dialog box. '
  23.           .Title = "Please select a file"
  24.  
  25.           ' Clear out the current filters, and add our own.'
  26.           .Filters.Clear
  27.           .Filters.Add "All Files", "*.*", 1
  28.           .Filters.Add "PDF File", "*.pdf", 2
  29.           .Filters.Add "JPG File", "*.jpg", 3
  30.           .Filters.Add "Access Databases", "*.MDB", 4
  31.           .Filters.Add "Access Projects", "*.ADP", 5
  32.  
  33.  
  34.           ' Show the dialog box. If the .Show method returns True, the '
  35.           ' user picked at least one file. If the .Show method returns '
  36.           ' False, the user clicked Cancel. '
  37.           If .Show = True Then
  38.  
  39.              'Loop through each file selected and add it to our text box. (Just one in our case)'
  40.                 For Each varFile In .SelectedItems
  41.                 strSelectedFile = varFile & "#" & varFile
  42.                 Next varFile
  43.                 CellText = strSelectedFile
  44.                 Do While InStr(1, CellText, "\") > 0
  45.                 SlashPosition = InStr(1, CellText, "\")
  46.                 CellText = Right(CellText, Len(CellText) - SlashPosition)
  47.                 Loop
  48.                 Me.ComboTracabilityRef.Value = CellText
  49.                 Me.strTracability_Reference.Value = strSelectedFile
  50.                 Else
  51.                 End If
  52.        End With
  53.        'The hyperlinkadded variable must be set to true after populating the trace ref combobox so that the code within the "Private Sub ComboTracabilityRef_Change()" subroutine does not run and remove the hyperlink.
  54.     HyperlinkAdded = True
  55.     End Sub
Thanks
Prashant
Jul 26 '10 #1

✓ answered by NeoPa

See How to Programmatically Create a Hyperlink on a Form for controlling what is shown and what is linked to in a HyperLink control.

3 5044
NeoPa
32,556 Expert Mod 16PB
See How to Programmatically Create a Hyperlink on a Form for controlling what is shown and what is linked to in a HyperLink control.
Jul 26 '10 #2
@NeoPa
Thanks
It worked fine now
Jul 27 '10 #3
NeoPa
32,556 Expert Mod 16PB
I'm very pleased to hear that Prashant :)
Jul 27 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

49
by: Allen Browne | last post by:
If you are looking for opinon on what's useful in Access 2007, there's a new article at: http://allenbrowne.com/Access2007.html Covers what's good (useful features), what's mixed (good and bad),...
29
by: Paul H | last post by:
Why the heck was this dropped? All my dbs use ULS even the complex ones. It aint perfect, it's too fiddly, but it works. How will I be able to say "These users can run these reports and these...
1
by: Eugene | last post by:
Hello All, I need a report in Access 2007 to show a dynamic image on every page. I have a table, and I store image's path in a cell in each of the rows. In 2003, I was able to do that using...
4
by: lupo666 | last post by:
Hi everybody, this time I have three problems driving me nuts :-((( (1) I have a report with 20 or so Yes/No "squares". Is there a way to either hide/show the "square" or change the yes/no...
2
nico5038
by: nico5038 | last post by:
Access 2007 Linkedtable manager refuses to relink tables having a field with the "Attachment" datatype. Problem: When placing a split database in another folder, the Linked table manager should...
2
by: sphinney | last post by:
Hi everyone. I have a form in my Access 2007 database with a Microsoft Office Document Imaging Viewer Control 12.0 object on it. The object is named "GRAPHIC_mdv". When the form opens I want to...
1
by: Mientje | last post by:
I've made an Access 2007 database to store information about the lessonplans I have to make every schoolyear. I want to export the data form the table "Lesvoorbereiding" (Lessonplans in English) to...
10
by: kujito | last post by:
Ok, here it goes. I got my queries straightened out and they return the data I want in the format I want(finally). The data are sorted alpha. descending by ProjectName. Each project has a unique...
6
TheSmileyCoder
by: TheSmileyCoder | last post by:
I need to create a table, where one of the memo fields shall be a Rich Text field. Can anyone help me with that? This is the code I currently have. Public Sub createConTable() 'Create the table...
0
by: prashantdixit | last post by:
Hi, I have beent trying importing Excel data with one column containing PDF/JPEG file name to access 2007. I have a Excel file with few columns One of the columns named as "Reference". The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.