M
Matt
Our company are migrating an MS Office XP database to Access2003. The
database file format is already in 2002 format so I didn't expect much
trouble, however we use the database as a container for forms and
connect to our back end using ODBC Direct. I have a very strange
problem in that if I retrieve a SQL 'text' field which contains null
and try and put the result in an unbound text box and then try and use
that value ie:
txtBoxCustomerName = rstCustomers![CustomerName]
Debug.Print txtBoxCustomerName
I get the following error:
"Run-time error '2004':
There isn't enough memory to perform this operation.
Close unneeded programs and try the operation again."
Our problem can be simulated by connecting to the Northwind database
with this snippet of code, which works fine in VB6, AccessXP. I can
even code put it in our access2003 database save and then open in
access XP and it work, but running in Access 2003 errors:
' Notes:
' Requires connection suitable to point to a SQL MS Northwind database
and a textbox on the form called txtResult
Private Sub LoadANullTextField()
Dim wSQL As DAO.Workspace
Dim cSQL As DAO.Connection
Dim rEmployee As Recordset
Const c_sServerName As String = "SERVER-SQL"
Const c_sServerConnection As String = "ODBC;DRIVER={SQL
Server};SERVER=" & c_sServerName &
";Trusted_Connection=yes;database=Northwind"
Const c_sSelectStatement As String = "SELECT * FROM employees WHERE
(EmployeeID = 10)"
Set wSQL = DBEngine.CreateWorkspace("", "", "", dbUseODBC)
Set cSQL = wSQL.OpenConnection("", dbDriverNoPrompt, False,
c_sServerConnection)
If cSQL Is Nothing Then
MsgBox ("Failed to connect to Sql Server : " & c_sServerName)
Else
'Find an employee where we know the notes field is null
Set rEmployee = cSQL.OpenRecordset(c_sSelectStatement,
dbOpenSnapshot)
If Not rEmployee.EOF Then
txtResult = rEmployee![Notes]
' Now txtResult contains duff info and will produce error
2004 as above.
Debug.Print txtResult
End If
rEmployee.Close
cSQL.Close
End If
End Sub
Please could anyone try this sample piece of code and see if they can
reproduce the bug.
Client Machine Setup:
WindowsXP SP2
MSAccess 2003 Pro SP2
DAO360
Server
MS SQL 7 OR MS SQL 2005
Thanks Matt
database file format is already in 2002 format so I didn't expect much
trouble, however we use the database as a container for forms and
connect to our back end using ODBC Direct. I have a very strange
problem in that if I retrieve a SQL 'text' field which contains null
and try and put the result in an unbound text box and then try and use
that value ie:
txtBoxCustomerName = rstCustomers![CustomerName]
Debug.Print txtBoxCustomerName
I get the following error:
"Run-time error '2004':
There isn't enough memory to perform this operation.
Close unneeded programs and try the operation again."
Our problem can be simulated by connecting to the Northwind database
with this snippet of code, which works fine in VB6, AccessXP. I can
even code put it in our access2003 database save and then open in
access XP and it work, but running in Access 2003 errors:
' Notes:
' Requires connection suitable to point to a SQL MS Northwind database
and a textbox on the form called txtResult
Private Sub LoadANullTextField()
Dim wSQL As DAO.Workspace
Dim cSQL As DAO.Connection
Dim rEmployee As Recordset
Const c_sServerName As String = "SERVER-SQL"
Const c_sServerConnection As String = "ODBC;DRIVER={SQL
Server};SERVER=" & c_sServerName &
";Trusted_Connection=yes;database=Northwind"
Const c_sSelectStatement As String = "SELECT * FROM employees WHERE
(EmployeeID = 10)"
Set wSQL = DBEngine.CreateWorkspace("", "", "", dbUseODBC)
Set cSQL = wSQL.OpenConnection("", dbDriverNoPrompt, False,
c_sServerConnection)
If cSQL Is Nothing Then
MsgBox ("Failed to connect to Sql Server : " & c_sServerName)
Else
'Find an employee where we know the notes field is null
Set rEmployee = cSQL.OpenRecordset(c_sSelectStatement,
dbOpenSnapshot)
If Not rEmployee.EOF Then
txtResult = rEmployee![Notes]
' Now txtResult contains duff info and will produce error
2004 as above.
Debug.Print txtResult
End If
rEmployee.Close
cSQL.Close
End If
End Sub
Please could anyone try this sample piece of code and see if they can
reproduce the bug.
Client Machine Setup:
WindowsXP SP2
MSAccess 2003 Pro SP2
DAO360
Server
MS SQL 7 OR MS SQL 2005
Thanks Matt