Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Dynamically connecting to a remote database | Excel Discussion (Misc queries) | |||
Connecting to a database | Excel Programming | |||
Connecting To a Excel Database | Excel Programming | |||
Connecting to External Database | Excel Programming | |||
Excel Connecting to SQL Server Database - Need your Help | Excel Programming |