hceonetman
Technical User
Pretty new to VB coding. I am trying to create a VB module within an Access2000 database to populate a record in a table. This record will then serve as the datasource for a report. The requirements of the report make this too complicated to do within queries. My plan is to open a table with one record and then change each field based on values in other tables and queries. First I took code out of a book to just open and display fields in the table, and this doesn't work. Following is the code:
Sub DisplayFields()
Dim Connection As ADODB.Connection
Dim Catalog As ADOX.Catalog
Dim RecordSet As ADODB.RecordSet
Dim Field As Field
Connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=Q:\Dev\TestPayins\Payins.mdb"
Set Catalog.ActiveConnection = Connection
RecordSet.Open "Tbl_Aud_Revenue_Rcpt", Catalog.ActiveConnection, adOpenKeyset
RecordSet.Fields.Refresh
For Each Field In RecordSet.Fields
Debug.Print Field.Name & ", "; Field.Type & ", " & Field.ActualSize
Next
RecordSet.Close
Set RecordSet = Nothing
Set Catalog = Nothing
Connection.Close
Set Connection = Nothing
End Sub
I don't know if this is the correct method of opening a table in the current database. I get the error:
"the database has been placed in a state by user admin on machine CPU04 that prevents it from being opened or locked".
No one else is using the MDB, and I am identified as user Admin on my PC.
Also, recommendations on a good book to get up to speed in VB for Access programming would be welcome.
Thanks,
HCEONETMAN
The less things change, the more they remain the same.
Sub DisplayFields()
Dim Connection As ADODB.Connection
Dim Catalog As ADOX.Catalog
Dim RecordSet As ADODB.RecordSet
Dim Field As Field
Connection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=Q:\Dev\TestPayins\Payins.mdb"
Set Catalog.ActiveConnection = Connection
RecordSet.Open "Tbl_Aud_Revenue_Rcpt", Catalog.ActiveConnection, adOpenKeyset
RecordSet.Fields.Refresh
For Each Field In RecordSet.Fields
Debug.Print Field.Name & ", "; Field.Type & ", " & Field.ActualSize
Next
RecordSet.Close
Set RecordSet = Nothing
Set Catalog = Nothing
Connection.Close
Set Connection = Nothing
End Sub
I don't know if this is the correct method of opening a table in the current database. I get the error:
"the database has been placed in a state by user admin on machine CPU04 that prevents it from being opened or locked".
No one else is using the MDB, and I am identified as user Admin on my PC.
Also, recommendations on a good book to get up to speed in VB for Access programming would be welcome.
Thanks,
HCEONETMAN
The less things change, the more they remain the same.