Pass field into hyperlink/button

davea300

Registered User.
Local time
Today, 00:35
Joined
Mar 16, 2007
Messages
164
I'm trying to pass a field ([txtUPRN]) in a form to a hyperlink or button on the form.

e.g. http://whatever/GetJobsByLocation?jlocation= 26800

I thought I could add a hyperlink and simply change the part 'jlocation = 26800' to 'jlocation = Me![txtUPRN]' but this would be too easy as it doesn't work. THe URL still opens a web page but displays no data. Do I have to be more explicit as to what I'm passing in i.e. use the full form name or am I going about this the wrong way?
 
Could you show the complete code you have behind the button? try.
Code:
"http://whatever/GetJobsByLocation?jlocation = "& [B]Me[COLOR=Red].[/COLOR][/B][txtUPRN]
 
I currently have a button which simply opens another access form and displays the data I want:

Private Sub cmdJobs_Click()
On Error GoTo Err_cmdJobs_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmJJOBH"

stLinkCriteria = "[JLOCATION]=" & "'" & Me![txtUPRN] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdJobs_Click:
Exit Sub
Err_cmdJobs_Click:
MsgBox Err.Description
Resume Exit_cmdJobs_Click

End Sub

but I really need this button to open this URL:


http://api.mvcservitor/GetJobsByLocation?jlocation=25008


and pass in the field Me![txtUPRN] instead of the number 25008 above. The URL above is the full code I have for the hyperlink.
 
Okay try this code.. This should work..
Code:
Private Sub cmdJobs_Click()
On Error GoTo Err_cmdJobs_Click
    Dim urlPath As String
    urlPath = "http://api.mvcservitor/GetJobsByLocation?jlocation="[COLOR=Blue][B] & Me.[txtUPRN][/B][/COLOR]
    [URL="http://msdn.microsoft.com/en-us/library/office/aa204494%28v=office.10%29.aspx"]Application.FollowHyperlink[/URL] urlPath
Exit_cmdJobs_Click:
    Exit Sub
Err_cmdJobs_Click:
    MsgBox Err.Description
    Resume Exit_cmdJobs_Click
End Sub
 

Users who are viewing this thread

Back
Top Bottom