Results 1 to 13 of 13
  1. #1
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317

    Creating a hyperlink from two separate table fields

    Hi Folks



    Is it possible to create a hyperlink in a query from three* separate table fields, e.g. SiteName, URL and Screentip? I can't work out the code. For example, 'Hyperlink: [Table.SiteName] & "#" & [Table.URL] & "##" & [Table.Screentip]' just generates 'Website#www.website.com#Open_Website' in the query.

    The reason why SiteName, URL and Screentip are separate fields is that I want the site name, URL and screentip to be input separately in the form that's used to populate the table.

    Thanks

    Remster

    *Edit

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Remster,

    This is not to be done at any 'dataset' level. What you'll want to do is just concat the fields, leave the string values in the query as is, then on your forms and reports, color and underline the text appropriately. you will want to make it a hyperlink with an 'on-click' event and one line of code:
    Code:
    application.followhyperlink screen.activecontrol.name
    (code may not be 100% there). I'm not sure if the 'hyperlink hand' cursor type is available in 03, but it is in 07. That's another that can be changed to make the user think it really is a hyperlink.

    and then of course, when you say 'screentip', if you're really talking about a webpage bookmark (anchor), you'll have to concat in a pound sign in the actual value at the query level so the user will be taken to that part of the page when clicking.

  3. #3
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    ajetrumpet

    Many thanks for getting back to me.

    Just a point of clarification before I enquire any further. By '"dataset" level' are you referring to tables or to both tables and queries? What I want are three separate fields in my table (SiteName, URL and Screentip) and the same three separate fields in the corresponding form, but a combined hyperlink field in my query, like this: Website. I need the hyperlink field in the query because the query is to be exported to HTML to create the contents of a Webpage.

    An acceptable alternative would be to have a fourth, hidden, field in the form that calculates the hyperlink from the values entered in the SiteName, URL and Screentip fields and sends it to a fourth field in the table. I can't work out how to do this though!

    By the way, I really do mean 'Screentip'. According to MS Access Help, the structure of a hyperlink is 'displaytext#address#subaddress#screentip'.

    Remster

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    okie dokie.

    well...I don't think you can do that from within a query. could be wrong though.

    and yes....'dataset' means 'query' or 'table'. so...if you want to export this stuff out via html, I don't think you can it either, because a database outputted to html through the wizard will automatically read the table fields AND their values as just that, values. It will not recognize an html hyperlink syntax, nor will it recognize pound signs for what you're thinking about them.

    However, you can export through code and use vba to write the file yourself and completely forego the wizard. If you do it that way, you can make the values in the dataset whatever you want. Here is Allen Browne's suggestion for doing so: http://allenbrowne.com/AppOutputHtml...tml#OutputHTML

  5. #5
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    I've been directed to that Allen Browne link before, but I didn't really understand what to do. I'll have another look in the next couple of days.

    The way my experimental database works at the moment (this is very much WIP) is that the user enters 'displaytext#address##screentip' into the form, and then both the table and the query contain the resulting hyperlink ('display text'). The HTML page generated from the query is then exactly as I want it. Is it all right to have hyperlinks within tables?

    If so, what about the possibility I suggested of combining the displaytext and address in an invisible field in the form. Would that be possible? Then the user would enter them into different fields but they'd be combined before reaching the table.

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Remster View Post
    Is it all right to have hyperlinks within tables?
    This is the last time I'll say this: NO. I said it 3 times already. version 07 has a hyperlink field, but you can't manipulate what it outputs via an export (code wise). I don't think.

    Quote Originally Posted by Remster View Post
    If so, what about the possibility I suggested of combining the displaytext and address in an invisible field in the form. Would that be possible?
    YES. and AGAIN, it doesn't matter what you put in field a, b, c, or field 500. combine whatever you want, whenever you want. I think the point that you're missing here is that Access will not recognize this line for anything:
    Code:
    www.domain.com#mysection#myothersection
    if you compare the interpretation abilities of the Jet engine with HTML parsing, they are completely unrelated. Pound signs mean nothing in Access within the context you're talking about. (as far as I know).

    if that doesn't make sense, what that means is that this:
    Code:
    www.domain.com/#bookmark
    written inside of an <a> tag in HTML is 100% opposite from the same code written in an Access table. In Access, Jet reads that code as a string, nothing else. To Access, it is simply 24 bytes of memory to process. make sense?

    and...if I haven't already covered this, you need to understand that if you're eventual output in a field is going to be this:
    Code:
    site#url##screentip
    that means absolutely nothing until you get it into a program that is designed to interpret it properly. e.g. - "go to this website and scroll down to this section".

    HTH

  7. #7
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    Quote Originally Posted by ajetrumpet View Post
    Quote Originally Posted by Remster View Post
    Is it all right to have hyperlinks within tables?
    This is the last time I'll say this: NO. I said it 3 times already.
    But the question I'm asking has changed! Originally I was asking whether it's possible to combine two fields by means of a query to create a displaytext hyperlink. Now I'm asking whether it's advisable to enter displaytext hyperlinks into a table. Despite what you say, I know it's possible to do this, because I've done it; and I've successfully exported the data to an HTML document containing the hyperlinks. Here's what I entered into the table, in a field with the Data Type 'Hyperlink':
    Google#http://www.google.co.uk/
    And here's what came out in the HTML document:
    <A HREF="http://www.google.co.uk/">Google</A>
    What I'm trying to find out now is whether I'm storing up any problems for myself in having a field with the Data Type 'Hyperlink' in a table (just as I was warned I would be if I had a field with the Data Type 'Lookup').

    Quote Originally Posted by ajetrumpet View Post
    Quote Originally Posted by Remster View Post
    [W]hat about the possibility I suggested of combining the displaytext and address in an invisible field in the form. Would that be possible?
    YES.
    Then please tell me how! If it doesn't work, so be it. But at the moment I can't even work out what I have to do what code to write or where to stick it.

  8. #8
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    I appreciate your persistence Remster.

    Quote Originally Posted by Remster View Post
    Here's what I entered into the table, in a field with the Data Type 'Hyperlink':
    Google#http://www.google.co.uk/
    And here's what came out in the HTML document:
    <A HREF="http://www.google.co.uk/">Google</A>
    What I'm trying to find out now is whether I'm storing up any problems for myself in having a field with the Data Type 'Hyperlink' in a table (just as I was warned I would be if I had a field with the Data Type 'Lookup').
    IMO, NO you're not. I don't see anything wrong with hyperlinks. Never heard much news about them being evil.

    Quote Originally Posted by Remster;3493[W
    hat about the possibility I suggested of combining the displaytext and address in an invisible field in the form. Would that be possible?
    you have this in your query field (as state by you, above):
    Code:
    Google#http://www.google.co.uk/
    what do you mean by COMBINE? concat? Or make it actually 'be' a hyperlink on the form?

    I would assume the latter. if that is the case, bind a textbox on your form to the query field. it's as simple as that. the hyperlink will display automatically. make sense?

    I can't remember what the properties are of those types of fields, but check them out for yourself. if there is a 'display text' property, obviously you'll have to cut out the "google #" characters because that looks bad.

    so, get a field on that form, click the link and see what it does!

  9. #9
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    I think this might be something like what you're describing:

  10. #10
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    If you only want the final links displayed when exporting to HTML, create a query to only show the desired fields (probably with aliased headings) and then export from the query instead of the table.

  11. #11
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    slave 138 has the answer! For anyone who's interested, see the attachment two posts ago. Thank you.

    ajetrumpet, many thanks for sticking with it and sorry for not explaining myself very well. For what it's worth, I think I meant 'concat', but I couldn't get it to work.

  12. #12
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Happy to help

  13. #13
    Accesser is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    1
    Quote Originally Posted by slave138 View Post
    I think this might be something like what you're describing:
    Thank you slave138! This is just the solution I was hunting for.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. hyperlink data not transferring to destination table
    By markjkubicki in forum Programming
    Replies: 3
    Last Post: 09-17-2010, 06:12 PM
  2. Combine 2 Fields to make a hyperlink
    By ahightower in forum Forms
    Replies: 2
    Last Post: 06-30-2010, 08:59 PM
  3. multiple fields in separate records
    By Fredo0709 in forum Database Design
    Replies: 9
    Last Post: 04-09-2010, 12:23 PM
  4. Creating Report using Text boxes & db fields
    By Nancy J. in forum Reports
    Replies: 13
    Last Post: 07-20-2009, 07:09 AM
  5. Splitting a field to separate fields
    By Petefured in forum Programming
    Replies: 8
    Last Post: 06-08-2009, 04:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums