Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default connecting database curopting excel

Hi

I connect to a access database from excel for data. After this I can not
type in any cell or close excel.

I can close the workbook but have to use taskmanager to end task excel.

What can the problem be?

Please see macro below:

Sub loadtlname()

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim WSOrig As Worksheet
Dim WSTemp As Worksheet
Dim sSQL As String
Dim FinalRow As Long
Set WSOrig = ActiveSheet

'Build a SQL String to get all fields for unsent transfers
un = "'" & Range("s22").Value & "'"
sSQL = "SELECT [name].U, [name].Firstname, [name].Surname "
sSQL = sSQL & " FROM [name] WHERE ((([name].U)=" & un & " ));"

' Path to Transfers.mdb
MyConn = "c:\callstaffmdb.mdb"

Set cnn = New ADODB.Connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MyConn
End With
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer
rst.Open Source:=sSQL, ActiveConnection:=cnn, _
CursorType:=AdForwardOnly, LockType:=adLockBatchOptimistic, _
Options:=adCmdText

Range("o6").CopyFromRecordset rst

' Close the connection
rst.Close
cnn.Close



Set cnn = Nothing
Set rst = Nothing
Set WSOrig = Nothing
Set WSTemp = Nothing


Set WSOrig = Nothing
Application.DisplayAlerts = True
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically connecting to a remote database Tony Excel Discussion (Misc queries) 0 April 14th 08 05:35 PM
Connecting to a database cmpcwil2[_20_] Excel Programming 1 May 30th 06 01:56 PM
Connecting To a Excel Database NOODLES101487 Excel Programming 1 October 14th 05 02:26 PM
Connecting to External Database Geert Excel Programming 1 January 10th 05 04:46 PM
Excel Connecting to SQL Server Database - Need your Help Rajesh G Excel Programming 2 February 27th 04 08:01 PM


All times are GMT +1. The time now is 01:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"