Link to server

G

Guest

I have a db with job related info that opens a form based on a job number. I
want to put a command button that when clicked will open the server where
pics are located in folders by each job number and I want it to open the
specific job number the form is open to. Is this possible with code on
either "After Update" or "On Click"?
Also, I've put a couple of post with no reply as to how to show a calculated
field in one db show up in another db. Is this possible as well?
The help is greatly appreciated.
Thanks,
Phisaw
 
A

Albert D.Kallal

PHisaw said:
I have a db with job related info that opens a form based on a job number.
I
want to put a command button that when clicked will open the server where
pics are located in folders by each job number and I want it to open the
specific job number the form is open to. Is this possible with code on
either "After Update" or "On Click"?

Sure, build what we call a un-bound form. This is just a form to "prompt"
the user. There would a be text box for the user to enter the job number,
and a button called "view"

The code behind the button would be

docmd.OpenForm "jobedit",,,"Jobnumber = " & me.txtJobNum

The above would thus launch your job edit form..and load the ONE record with
the job number you typed in. The above assumes that jobnumber is a number
field...if it is text..then you have to surrounded the value with quotes,
like

docmd.OpenForm "jobedit",,,"Jobnumber = '" & me.txtJobNum & "'"

note:
docmd.OpenForm "jobedit",,,"Jobnumber = ' " & me.txtJobNum & " ' "
(for readability..I put in extra spaces so you can see where the quotes
go....but remove the extra spaces in your code).

as for loading the image, assuming the image has the SAME number as the job,
then you can in the forms on-load event go

dim strPath as string

strPath = \\servername\data\images\

strPath = strPath & me.jobnumber & ".jpg"

Me.Image32.Picture = strPath


The above assumes you placed a "image" contorl on the form (called image32
in the above...but you can call it whatever you want)
 
G

Guest

Albert - thanks for answering. I tried the code you gave and at
strPath=\\servername\date\images\
it gives me the error msg
"Compile Error
Expected: expression"
and highlights the first two backward slashes after the equal sign and turns
the line of text red. If you will tell me what I'm doing wrong, it wil be
greatly appreciated!!
Thanks,
Phisaw
 
A

Albert D.Kallal

PHisaw said:
Albert - thanks for answering. I tried the code you gave and at
strPath=\\servername\date\images\

The above needs to be

strPath = \\servername...bla bal bal

You have to surround any text string with quotes (my mistake...it was "air"
code as I typed the response - but, actaully what happned was outlook
express removed the quotes as I typed the message....).

note:

strPath = "dog"

msgbox "a " & strPath & " is a animal"

The above would result in a msgbox display of

a dog is a animal

So, general strings in VBA are created by placing "quotes" around the text
you want....

So,
strPath=\\servername\date\images\
needs to be

strPath = " \\servername\date\images\ "

In fact, you don't need the extra spaces in the above as I have it....but, I
can't type it as correct...since the outlook express editor removes the
quotes as I typed the message.

so:
strPath = "path name you want goes here"
 
G

Guest

Albert - Thanks for clearing that up for me - code is confusing and all the
help you guys provide is greatly appreciated!!
I did get past the first line with the server path, but I'm opening folders
with the same number as jobnumber from the form not individual pics. Ex:
JobNumber in field on form is 6761. I want to go to \\servername\data\ but
I don't have images, I have several folders, one being 6761 that I want to
open that contains several pictures related to this job number. I looked
thru the list that came up after Me.Image32. and nothing came up that looked
like it would work to make a folder with same job number open.
I'm sorry if the first post was confusing about going directly to one pic on
server.
Thanks again for the help!
Phisaw
 
A

Albert D.Kallal

Do you want to just open the folder..and let the user look in the windows
folder...

Or, do you want to display the pictures on the form (which of course would
mean you need some next/previous buttons to display each image).
Me.Image32. and nothing came up that looked
like it would work to make a folder with same job number open.
I'm sorry if the first post was confusing about going directly to one pic
on
server.

I am not away of any type of control that will just willy nilly work its way
though a directory and start display pictures. (and, not clear where/how
those pictures are to be displayed). A image control on the form will allow
you to a image.

So, you can either provide some type of interface to view the next/previous
image, or you can open up the windows folder (explorer).

The code to open up the folder would be

strPath = "path name to your folder"

eg somting like : : \\servername\foldername\

So, perahps something like

strPath = " \\servrename\productpictures\" & me.Jobnumber & "\"

application.FollowHyperlink strPath

The above would thus open the folder.

Of course, you can/could still use the image control..but it would only
display 1 image at time..and you would thus provide next/previous set of
buttons.... (check out the help..and the dir command as to how to fetch each
file name in a given directory...).
 
G

Guest

Albert - I want to open the folder and let the user look at the pics in the
folder and the code you gave worked like a charm! Thank you soooo much for
your help!!
I do have one other question I hope you will help me with and then I believe
I will finally have this db ready to work in.
I have a text box on my main form (fGeneralInfo)that calculates the total of
time spent on job from the subform (fWorkLog2).

=fWorkLog2.Form!TotalJobTime

This is in the "TimeDatabase". I want to display this total in another
database "JobDatabase". They are both on the same server, if that makes a
difference. Is there a way to do this? I've tried everything I can think of
and when it comes to coding - it's not much. Again, thanks for the time and
help!!
Phisaw
 
A

Albert D.Kallal

Well, that other database must have a link, or some type of way of looking
at the total

You can create a linked table in the other database to the details with the
time.

you can then place a text box on a form, and go

=(dsum("[fieldToTotal]","[NameOFourLinkedTable]","jobnumber = 134")

The above would show the same total for the given job number. I don't know
exactly where/how you need to grab the total..but you can certainly tell
ms-access to generate that total anytime you need it.

So, if you need that value somewhere...then simply generate it...
 
G

Guest

Hi Albert, I was hoping there was a way with code like a hyperlink like we
did with the pics on the server without linking the tables. But if that's
the only way then I can do that. As I said, the code for opening the pic
folder on the server worked great except now I need a message something like
"No Pics Available for This Job" instead of the Runtime msg that appears. I
tried to come up with something, but nothing worked for me. Not sure how to
get a conditional expression here.
strPath = " \\servrename\productpictures\" & me.Jobnumber & "\"

application.FollowHyperlink strPath

Thank you,
Phisaw
 
A

Albert D.Kallal

strPath = " \\servrename\productpictures\" & me.Jobnumber & "\"

if dir(strPath,vbDirectory) = "" then

msgbox "no picutre"

else

application.FollowHyperlink strPath

end if
 

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

Similar Threads

Subform New Record 2
Message Box 2
dynamically change hyperlink address on form 7
Subform & Main Form Control 6
Quote Form with Options 9
Filter Information. 2
Combo Selections 7
Dialog Box 3

Top