use Record Selector to send records to web page

E

efandango

I want to be able to select any group of records on a continuous form using
the record selector and send the chosen records to an external web browser.
The code I have below will parses a set of records from a table to a web
browser, but I want to do it from a form, and be able to select from any
contiguous set of the displayed records.

How can I determine which is the the first, last and the in between records
and how do I pass them through to the browser? can someone advise on how I
can modify my existing code to do this?.

My form is called : Forms![frm_Runs]![frm_Run_Reveal_Target]


this is my exisiting code:

Private Sub btn_Run_Test_Show_Map_Click()
'Assume lngRunNo is either declared elsewhere or passed as an argument
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sRoute As String
Dim iWPCount As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("Select [Run_waypoint], [Postcode] from
tbl_Run_Reveal_Target where [Run_No]=" & Me.Run_No & " and [Postcode]<> 'X'
order by [OrderSeq];", dbOpenForwardOnly)


Do Until rs.EOF
iWPCount = iWPCount + 1
sRoute = sRoute & IIf(iWPCount = 1, "from: ", " to: ") &
rs![Run_waypoint] & ", " & "London, " & rs![Postcode]
rs.MoveNext
Loop
rs.Close

If iWPCount >= 2 Then

Parent.Form.Run_Test_WebBrowser.Navigate
"http://maps.google.co.uk/maps?f=q&hl=en&q=" & sRoute

Else
MsgBox "Run must have at least two waypoints"
End If
End Sub
 
E

efandango

Tom,

I managed to create the Msoft example where it displays each address name in
a message box, but I need help on how to parse the selected collection of
addresses to the browser instead of to a sequential message box.

This is what I now have in my module:

Option Compare Database
Option Explicit

Function DisplaySelectedCompanyNames()
Dim i As Long
Dim F As Form
Dim RS As Recordset

' Get the form and its recordset.
Set F = Forms![frm_Runs]![frm_Run_Reveal_Target].Form
Set RS = F.RecordsetClone

' Move to the first record in the recordset.
RS.MoveFirst

' Move to the first selected record.
RS.Move F.SelTop - 1

' Enumerate the list of selected records presenting
' the CompanyName field in a message box.
For i = 1 To F.SelHeight
MsgBox RS![Run_waypoint]
RS.MoveNext
Next i

End Function


This is what I want to send to the browser, which represents the two fields
+ "London" in each record.

[Run_waypoint] & ", " & "London " & rs![Postcode]


The code below is what I have on another form that takes a Complete/All set
of records from the a form's underlying table, where it loops through each
record and adds the address fields to the string "sRoute". But I need my
record selector to do the same with the selected records.

Other form's code:

Private Sub btn_Points_Maker_Venues_ShowMap_Click()
'Assume lngRunNo is either declared elsewhere or passed as an argument
Dim db As DAO.Database
Dim RS As DAO.Recordset
Dim sRoute As String
Dim iWPCount As Integer
Set db = CurrentDb
Set RS = db.OpenRecordset("Select [Run_point_Venue],
[Run_Point_Postcode]from tbl_Points_Maker where [Run_No]=" & Me.Run_No & "
order by [Points_Maker_ID];", dbOpenForwardOnly)

Do Until RS.EOF
iWPCount = iWPCount + 1
'sRoute = sRoute & IIf(iWPCount = 1, "from: ", " to: ") &
rs![Link_waypoint]
sRoute = sRoute & IIf(iWPCount = 1, "from: ", " to: ") &
RS![Run_point_Venue] & ", " & "London " & RS![Run_Point_Postcode]
RS.MoveNext
Loop
RS.Close

If iWPCount >= 2 Then

Parent.Form.PointsMaker_WebBrowser.Navigate
"http://maps.google.co.uk/maps?f=q&hl=en&q=" & sRoute

Else
MsgBox "Run must have at least two waypoints"
End If
End Sub




Tom van Stiphout said:
On Sat, 21 Mar 2009 00:36:01 -0700, efandango

Check out this article:
http://support.microsoft.com/kb/294202

-Tom.
Microsoft Access MVP

I want to be able to select any group of records on a continuous form using
the record selector and send the chosen records to an external web browser.
The code I have below will parses a set of records from a table to a web
browser, but I want to do it from a form, and be able to select from any
contiguous set of the displayed records.

How can I determine which is the the first, last and the in between records
and how do I pass them through to the browser? can someone advise on how I
can modify my existing code to do this?.

My form is called : Forms![frm_Runs]![frm_Run_Reveal_Target]


this is my exisiting code:

Private Sub btn_Run_Test_Show_Map_Click()
'Assume lngRunNo is either declared elsewhere or passed as an argument
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sRoute As String
Dim iWPCount As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("Select [Run_waypoint], [Postcode] from
tbl_Run_Reveal_Target where [Run_No]=" & Me.Run_No & " and [Postcode]<> 'X'
order by [OrderSeq];", dbOpenForwardOnly)


Do Until rs.EOF
iWPCount = iWPCount + 1
sRoute = sRoute & IIf(iWPCount = 1, "from: ", " to: ") &
rs![Run_waypoint] & ", " & "London, " & rs![Postcode]
rs.MoveNext
Loop
rs.Close

If iWPCount >= 2 Then

Parent.Form.Run_Test_WebBrowser.Navigate
"http://maps.google.co.uk/maps?f=q&hl=en&q=" & sRoute

Else
MsgBox "Run must have at least two waypoints"
End If
End Sub
 
E

efandango

Tom, anyone?

can you give me some advice in regards my last message?



Tom van Stiphout said:
On Sat, 21 Mar 2009 00:36:01 -0700, efandango

Check out this article:
http://support.microsoft.com/kb/294202

-Tom.
Microsoft Access MVP

I want to be able to select any group of records on a continuous form using
the record selector and send the chosen records to an external web browser.
The code I have below will parses a set of records from a table to a web
browser, but I want to do it from a form, and be able to select from any
contiguous set of the displayed records.

How can I determine which is the the first, last and the in between records
and how do I pass them through to the browser? can someone advise on how I
can modify my existing code to do this?.

My form is called : Forms![frm_Runs]![frm_Run_Reveal_Target]


this is my exisiting code:

Private Sub btn_Run_Test_Show_Map_Click()
'Assume lngRunNo is either declared elsewhere or passed as an argument
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sRoute As String
Dim iWPCount As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("Select [Run_waypoint], [Postcode] from
tbl_Run_Reveal_Target where [Run_No]=" & Me.Run_No & " and [Postcode]<> 'X'
order by [OrderSeq];", dbOpenForwardOnly)


Do Until rs.EOF
iWPCount = iWPCount + 1
sRoute = sRoute & IIf(iWPCount = 1, "from: ", " to: ") &
rs![Run_waypoint] & ", " & "London, " & rs![Postcode]
rs.MoveNext
Loop
rs.Close

If iWPCount >= 2 Then

Parent.Form.Run_Test_WebBrowser.Navigate
"http://maps.google.co.uk/maps?f=q&hl=en&q=" & sRoute

Else
MsgBox "Run must have at least two waypoints"
End If
End Sub
 

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

Top