M
MikeB
In the online Help for Visual Basic, there is the following example
(I've removed some of the code for brevity in posting here, but not in
the example I'm running).
Sub FieldX()
Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
' removed some Dim statements
Dim fldIndex As Field
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees")
' removed some Assign statements
Set fldIndex = _
dbsNorthwind.TableDefs(0).Indexes(0).Fields(0)
' Print report.
' removed some output calls.
FieldOutput "Index", fldIndex
rstEmployees.Close
dbsNorthwind.Close
End Sub
I can't run this code, since I don't have the NorthWind database. So I
try to change the code as follows and get an error
Sub FieldX()
Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
Dim fldIndex As Field
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("C:\Documents and Settings\Mike\My
Documents\My MS Access Projects\FMEChessClub.mdb")
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Players") '<== I get an error
here
' Assign a Field object from different Fields
' collections to object variables.
Set fldIndex = _
dbsNorthwind.TableDefs(0).Indexes(0).Fields(0)
' Print report.
FieldOutput "Index", fldIndex
rstEmployees.Close
dbsNorthwind.Close
End Sub
The error I get says: Runtime Error '13' Type mismatch. Now I believe
that the database open call worked, since I can execute the Name
method on dbsNorthWind. Perhaps I'm mistaken?
(I've removed some of the code for brevity in posting here, but not in
the example I'm running).
Sub FieldX()
Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
' removed some Dim statements
Dim fldIndex As Field
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees")
' removed some Assign statements
Set fldIndex = _
dbsNorthwind.TableDefs(0).Indexes(0).Fields(0)
' Print report.
' removed some output calls.
FieldOutput "Index", fldIndex
rstEmployees.Close
dbsNorthwind.Close
End Sub
I can't run this code, since I don't have the NorthWind database. So I
try to change the code as follows and get an error
Sub FieldX()
Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
Dim fldIndex As Field
Dim prpLoop As Property
Set dbsNorthwind = OpenDatabase("C:\Documents and Settings\Mike\My
Documents\My MS Access Projects\FMEChessClub.mdb")
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Players") '<== I get an error
here
' Assign a Field object from different Fields
' collections to object variables.
Set fldIndex = _
dbsNorthwind.TableDefs(0).Indexes(0).Fields(0)
' Print report.
FieldOutput "Index", fldIndex
rstEmployees.Close
dbsNorthwind.Close
End Sub
The error I get says: Runtime Error '13' Type mismatch. Now I believe
that the database open call worked, since I can execute the Name
method on dbsNorthWind. Perhaps I'm mistaken?