Adding Value To New Record In Tabledef

TurboBeagle

New member
Local time
Today, 17:02
Joined
Apr 10, 2003
Messages
6
The first part of the module I am trying to create is where I am creating a new table based on an existing table. At this point, I am just trying to assign each record in the newly created table the same value as the records in the original table.

The error I keep getting is:

1-You tried to write to a read-only property. See the Help topic for the property to determine whether it is read/write.
2-You tried to use a method or property on a type of Recordset object that the method or property doesn't apply to. See the Recordset object Summary topic to determine which methods and properties apply to a given type of Recordset object.
3-You tried to append a property to a Properties collection of an object that doesn't support user-defined properties.
4-You tried to use the Update method on a read-only Recordset object.


Here's the code:


Public Function Disbursements()

Dim DB As Database
Dim FilterQuery As Recordset
Dim Disb As TableDef
Dim LO As Field
Dim Difference As Field


Set DB = CurrentDb


Set Disb = DB.CreateTableDef("DISB", acEdit)
Set Difference = Disb.CreateField("Difference", dbLong, 10)
Set LO = Disb.CreateField("LO", dbLong, 5)
Disb.Fields.Append Difference
Disb.Fields.Append LO
Disb.Fields.Refresh

Debug.Print Disb.Updatable
'the debug table says TRUE

Set FilterQuery = DB.OpenRecordset("Total Profile Summary Combined Calc Filter LO")

FilterQuery.MoveFirst

Do While Not FilterQuery.EOF
Disb!LO = FilterQuery!LO <==THIS IS WHERE IS STOPS, IT DOESN'T EVEN LOOP ONE TIME<======
FilterQuery.MoveNext
Loop


FilterQuery.Close


End Function


I AM DESPERATE!!! ANY HELP WOULD BE GREATLY APPRECIATED!!!!!!!!
 
Turbo,

I have never been a fan of creating or altering tables
programmatically. What you are doing can be done with
a Make Table query. It will be a lot easier.

Do a search here for "Make table query".

Wayne
 
I would like to point out what's wrong with the DAO code.

acEdit is not an attribute of CreateTableDef.

After appending the fields to the TableDef, you have to Append the TableDef to the DataBase. You can then open the table as a recordset and copy the records using the AddNew and Update methods of the recordset.

- - - - - - - - - - - - - -
Dim DB As Database
Dim FilterQuery As Recordset
Dim Disb As TableDef
Dim LO As Field
Dim Difference As Field

Set DB = CurrentDb


Set Disb = DB.CreateTableDef("DISB")

Set Difference = Disb.CreateField("Difference", dbLong, 10)
Set LO = Disb.CreateField("LO", dbLong, 5)
Disb.Fields.Append Difference
Disb.Fields.Append LO
Disb.Fields.Refresh

DB.TableDefs.Append Disb

Dim rsDisk As DAO.Recordset
Set rsDisk = DB.OpenRecordset("Disb")


Set FilterQuery = DB.OpenRecordset("Total Profile Summary Combined Calc Filter LO")

FilterQuery.MoveFirst

Do While Not FilterQuery.EOF

rsDisk.AddNew
rsDisk!LO = FilterQuery!LO
rsDisk.Update

FilterQuery.MoveNext
Loop


FilterQuery.Close
- - - - - - - - - - - - - -
 

Users who are viewing this thread

Back
Top Bottom