Re: Cant find Sheet1. Whats wrong with this code?
- From: "Diggy" <Diggy@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 14 Jan 2006 01:37:02 -0800
Godmorning Frank, and thanks for your reply. It worked! Giving me a god
morning to! Next, there is someting wrong with the search in the record set.
I expected to get a value in the textbox txtFastighetskarta, but no. Can you
have look at that to?
Thanks again for your working advice! / Diggy
"Frank Hickman [MVP]" wrote:
> "Diggy" <Diggy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:698D68B0-8E3D-4FA9-B6A8-41D0D0BBBA01@xxxxxxxxxxxxxxxx
> > My Sheet1 is named Blad1 below. I have tried everthing, but it still
> > doesn't
> > work.
> > Please, any suggestions?
> >
> > im aCon As ADODB.Connection
> > Dim aRec As ADODB.Recordset
> > Dim sqlQ As String
> > Dim aDbf As String
> > aDbf = "C:\Documents and Settings\Pappa\Mina
> > dokument\SVOInventeringar\RAHLP\Data\FastighetskartanBladNamn.xls"
> > '
> > On Error GoTo Err_Label
> > '
> > 'Define and open the connection
> > Set aCon = New ADODB.Connection
> > With aCon
> > .Provider = "Microsoft.Jet.OLEDB.4.0"
> > .ConnectionString = "Data Source=aDbf;" & "Extended Properties=Excel 8.0;"
> > .Open
> > 'Make a Query over the connection
> > sqlQ = "SELECT Kartindex, Ortnamn, Kartblad FROM [Blad1$] where
> > Kartindex='"
> > & MapIndex & "'"
> > End With
> > '
> > 'Define and open the recordset
> > Set aRec = New ADODB.Recordset
> > aRec.Open sqlQ, aCon, adOpenStatic, adLockReadOnly, adCmdText
> > '
> > 'Note: Column A is Fields(0), column B is Fields(1), column C is Fields(2)
> > MsgBox "Search the recordset"
> > Do Until aRec.EOF
> > If aRec.Fields(0) = MapIndex Then
> > Me.txtFastighetskarta.Text = CLng((aRec.Fields(2)))
> > End If
> > aRec.MoveNext
> > Loop
> > '
> > aRec.Close
> > aCon.Close
> > '
> > Set aRec = Nothing
> > Set aCon = Nothing
> > '
> > If txtFastighetskarta = "" Then MsgBox "No Kartblad Found"
> > '
> > Err_Label:
> > If Err.Number <> 0 Then
> > MsgBox "Error Description: " & Err.Description
> > End If
>
> Try changing
>
> .ConnectionString = "Data Source=aDbf;" & "Extended Properties=Excel 8.0;"
>
> to
>
> .ConnectionString = "Data Source=" & aDbf & ";Extended Properties=Excel
> 8.0;"
>
> --
> ============
> Frank Hickman
> Microsoft MVP
> NobleSoft, Inc.
> ============
> Replace the _nosp@m_ with @ to reply.
>
>
>
.
- Follow-Ups:
- Re: Cant find Sheet1. Whats wrong with this code?
- From: Frank Hickman [MVP]
- Re: Cant find Sheet1. Whats wrong with this code?
- References:
- Re: Cant find Sheet1. Whats wrong with this code?
- From: Frank Hickman [MVP]
- Re: Cant find Sheet1. Whats wrong with this code?
- Prev by Date: Re: Cant find Sheet1. Whats wrong with this code?
- Next by Date: Re: Cant find Sheet1. Whats wrong with this code?
- Previous by thread: Re: Cant find Sheet1. Whats wrong with this code?
- Next by thread: Re: Cant find Sheet1. Whats wrong with this code?
- Index(es):