Bob,
I hear you, but for now the purpose of the project dictates that both
numbers will be inputted. But something else has come up by way of you
introducing me to mutliple message boxes...
When this exported file goes into google earth, the <name> variable is fixed
to 'Run Points' like this:
Print #lngFN, "<name>Run Points " & strRun_No & "</name>"
So I added/replace these lines:
Dim FileTitle As String
FileTitle = InputBox("Enter the file title")
Print #lngFN, "<name>FileTitle " & strRun_No & "</name>"
but when I open the file, the title is literally 'FileTitle', I can see why
it has doen this, but can't work out how to have the code replace it with the
variable input from the message box; what am I overlooking here?
My Code:
**********************
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset
Dim strStartRun_No As String
Dim strEndRun_No As String
Dim FileTitle As String
' Dim strRun_No As String
Dim lngFN As Long
'Create empty text file
lngFN = FreeFile()
Open "W:\Folder\Addresses.kml" For Output As #lngFN
strStartRun_No = InputBox("Enter the lower Run No")
strEndRun_No = InputBox("Enter the higher Run No")
FileTitle = InputBox("Enter the file title")
If Len(strStartRun_No) > 0 Then
Set db = CurrentDb()
Set qdf = db.QueryDefs("Generate_KML_Run_Titles")
qdf.Parameters("StartRun") = strStartRun_No
qdf.Parameters("EndRun") = strEndRun_No
'Output header
'NB: need to double quotes in literal strings
Print #lngFN, "<?xml version=""1.0"" encoding=""UTF-8""?>"
Print #lngFN, "<kml xmlns=""http://earth.google.com/kml/2.0"">"
Print #lngFN, "<Document>"
Print #lngFN, "<name>FileTitle " & strRun_No & "</name>"
Print #lngFN, "<Folder>"
'Print #lngFN, "<name>Locations</name>"
Print #lngFN, "<open>1</open>"
Set rs = qdf.OpenRecordset(dbOpenSnapshot)
Do Until rs.EOF = True
'Print #lngFN, rs.Fields("KML_Address")
Dim strWork As String
strWork = rs.Fields("KML_Address")
strWork = Replace(strWork, "&", "&")
strWork = Replace(strWork, "'", "'")
'strWork = Replace(strWork, "<", "<")
Print #lngFN, strWork
rs.MoveNext
Loop
rs.Close
'Output footer
Print #lngFN, "</Folder>"
Print #lngFN, "</Document>"
Print #lngFN, "</kml>"
Close #lngFN
End If
On Error GoTo Err_Google_Earth_Points_Click
Dim stAppName As String
stAppName = "C:\Program Files\Google\Google Earth\GoogleEarth.exe
W:\Folder\Addresses.kml"
Call Shell(stAppName, 1)
Exit_Google_Earth_Points_Click:
Exit Sub
Err_Google_Earth_Points_Click:
MsgBox Err.Description
Resume Exit_Google_Earth_Points_Click
****************************
"Bob Barrows [MVP]" wrote:
> efandango wrote:
> > Bob, It worked!. But at first it didn't, instead it was outputting an
> > empty file. So I changed (figuring that the first line was no longer
> > true)
> >
> > this line: If Len(strRun_No) > 0 Then
> >
> > to this: If Len(strStartRun_No) > 0 Then
>
> Well, you should be testing both variables ...
> If Len(strStartRun_No) > 0 And Len(strEndRun_No) > 0 Then
> >
> >
> > I didn't know how to add another message box. I'm a novice at this,
> > and the original code was not my creation, but was created by another
> > helpful MVP some time ago. I simply adapted it for my use.
> >
>
> You might want to consider using an unbound form rather than InputBox
> statements. Let us know if you want to try it and need specifics.
>
> --
> Microsoft MVP - ASP/ASP.NET - 2004-2007
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>
>
>
|