By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,676 Members | 1,708 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,676 IT Pros & Developers. It's quick & easy.

click a button in form which opens a doc specific to that record

P: 6
Hey,

I was looking for some help re: the following- what i want to achieve is to click a button on a form which opens a document specific to the open record. The form is entitled 'employees' and i wish to open the cv of the employee whos record is open.

(Eg- if i had John Smith's record open, the path to the CV for John Smith is c:\me\desktop\Smith, John\cv.rtf)

Thank you for your time!!

Col
Oct 27 '06 #1
Share this Question
Share on Google+
6 Replies


pks00
Expert 100+
P: 280
If what u are saying is the folder name is Surname comma Forename
How is the name displayed on the form currently?

If u had seperate fields u could try this

FollowHyperlink "C:\me\desktop\" & Me.surname & ", " & Me.Forename & "\cv.rtf"
Oct 27 '06 #2

P: 6
col
PKS,

Thanks for getting back to me so promptly!! The data is stored as 2 separate fields in the form SURNAME and FIRSTNAME. The folder name is surname,forename- but i can change it all to surname if that makes it more likely to work.

I could not manage to get the solution you suggested working. Am i suppose to paste this into the hyperlink box, within properties of the button? If so, then no joy as yet. Also, as a newbie, i am assuming that the 'Me' you quote next to surname and forename should be replaced with the name of my form?

Thanks again,
Col
Oct 27 '06 #3

100+
P: 143
Unless me.surname and me.forename are filenames, then I'm afraid it won't work. FollowHyperlink works on path names. May I suggest a slightly different approach. You can still use the FollowHyerlink method as that is probably the simplest. Firstly,create a table with the following fields. CVID, autonumber CVPath,hyperlink Surname, text and Forename, text. In the CVPath field put the pathname to the file. e.g. C:\word\johnsmithcv.rtf On your employee form. add a command button. Behind the command button add this code.

Application.FollowHyperlink Me.CVPath, , True

Where CVPath is the name of your text box that holds the pathname. Me just refers to the control. Now when you click the button it should open at the correct document. Incidentally, you could use a combo box for the hyperlinks.
Oct 27 '06 #4

P: 6
col
Thanks for your help and advice!!

Im still a little confused. i dont understand how access would differentiate between which doc i wished to open. if i set the pathname as c:\...\...\johnsmith.rtf then surely only john smiths cv would be available.

Also, in which box of the table must i paste the pathname and does it have to be a new table or can it be the one i have been using to create the form?

Lastly, re: the Application.FollowHyperlink Me.CVPath, , True command- where exactly do i enter this?

Thanks again,

Col
Oct 27 '06 #5

pks00
Expert 100+
P: 280
PKS,

Thanks for getting back to me so promptly!! The data is stored as 2 separate fields in the form SURNAME and FIRSTNAME. The folder name is surname,forename- but i can change it all to surname if that makes it more likely to work.

I could not manage to get the solution you suggested working. Am i suppose to paste this into the hyperlink box, within properties of the button? If so, then no joy as yet. Also, as a newbie, i am assuming that the 'Me' you quote next to surname and forename should be replaced with the name of my form?

Thanks again,
Col

ok, two seperate fields no problem
folder name is surname,forename - is there a space in between? The worry here is if u had two different people with the same name. I would recommened u use a primary key, does your table have a autonumber or something?

say u had a btn called cmdOpen, u then use the click event
e.g.

private sub cmdOpen_Click()

Dim sParentDir as String
Dim sUserDir as String

sParentDir = "C:\me\desktop\" 'best to define this as constant
sUserDir = Me.Surname & "," & Me.Forename 'best to use ID here


FollowHyperlink sParentDir & sUserDir & "\cv.rtf"
end sub



The use of Me means u are going to use a method or property of the form
in this case the two controls that hold the name

type . after Me then u get the intellisense menu
Here u can see your 2 fields

Me.
Oct 27 '06 #6

P: 6
col
It worked!! thank you very much for your help. much appreciated!!

Col
Oct 30 '06 #7

Post your reply

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