Edit a value in a table from code 
Author Message
 Edit a value in a table from code

How can I edit the value in a column of a particular table, of a
particular row (record) from within code? I am not very familiar with
recordsets and can use some help with this probably simple procedure. I
know I can do it by calling a query, but is there a better way than
having to create a query for this procedure and running it... maybe just
define a temp update query or something? I want to basically change the
value in a yes/no field to the opposite of what it is.

Chad Waldman

P.S One more quick question... If you compact a database from within the
front-end, will it also compact the backend? If not, how can I compact
the backend (tables) from within the FE without ever having to close the
FE session?

Also, is compaction only for tables, or does it somehow compact the
whole database in general?



Thu, 03 May 2001 03:00:00 GMT  
 Edit a value in a table from code
Hi Chad,

You probuably want something like:

----------------------------
Dim dbs As Database
Dim rst As Recordset

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Put your SQL code here to find the particular
record(s)")

With rst
.MoveFirst
Do While .EOF = False
    .Edit
    !fieldname = newvalue
    .Update
    .MoveNext
Loop
 .Close
End With

Set dbs = Nothing
----------------------------

All the best,

Michael



Fri, 04 May 2001 03:00:00 GMT  
 Edit a value in a table from code
Quote:

>How can I edit the value in a column of a particular table, of a
>particular row (record) from within code? I am not very familiar with
>recordsets and can use some help with this probably simple procedure. I
>know I can do it by calling a query, but is there a better way than
>having to create a query for this procedure and running it... maybe just
>define a temp update query or something? I want to basically change the
>value in a yes/no field to the opposite of what it is.

>Chad Waldman

>P.S One more quick question... If you compact a database from within the
>front-end, will it also compact the backend? If not, how can I compact
>the backend (tables) from within the FE without ever having to close the
>FE session?

>Also, is compaction only for tables, or does it somehow compact the
>whole database in general?

Chad,

If you want the code to run from a form, then a line like
  Me!chkMyCheck= not Me!chkMyCheck
will toggle the value of the check box called chkMyCheck for the current
record.

Compacting 'front end' d/b will not compact a backend as well - they are
different databases. You can't compact a database whilst it is in use.

Whilst compacting mainly affects tables, it does reclaim other space as
well. (It also does other things as well).

Hope this helps.

Simon Lewis



Fri, 04 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to edit field values w/o updating table

2. Editing Registry Hex value by code

3. Access97 - Editing table hyperlink field by code

4. typical code for displaying and editing records from database table(s) in a grid in unbound mode

5. Change Default Value in Table by Code

6. getting custom outline code lookup table values

7. Code for Edit|Copy, Edit|Paste

8. Edit code and delete code in database.Help!

9. Value from a tbl to calc value in another table

10. ~Sum existing values with values from another table

11. ~Sum existing values with values from another table

12. Retrieval of value entered in one table to another table

 

 
Powered by phpBB® Forum Software