Edit field

asnyder

Registered User.
Local time
Today, 20:37
Joined
Jan 28, 2002
Messages
24
I used the following command to open a table and go to a specific record:

DoCmd.OpenTable "Donation Times"
Docmd.GoToRecord acDataTable, "Donation Times", acGoTo, 10

This works fine, but now that I am at the correct record, I want to change one of the fields. I tried the following, but I get the message can't find the field referred to in your expression.

If [Donation Times]!Donor2 = -1 then
[Donation Times]!Donor2 = 0
Else
[Donation Times]!Donor1 = 0
Endif

If I change the If statement to just the field name, I don't get the error, but the field doesn't change. Any suggestions would be appreciated.
 
Is your code too large to past it all? I'm not as experienced as others so it helps when I see larger chunks.

My guess would be a "bad naming convention" with that space in the table name. Would renaming the table and it's instances in your code take too long?

Is there a defined recordset? So you could rst![Donor2] = 0?
 
My first reaction is: oh my gosh.

I can see that you're trying to alter the value of a field in your table, but you're going about it in a very haphazard way. At the very least, your record may or may not always be the 10th record listed in the table.

Where are you running the code from? You should open the table as a recordset and use the Seek or FindFirst commands to locate the record based on criteria (not location), then edit it.
 
The naming convention was fine. I finally got it to work, by changing my control source to the table, instead of opening and closing it. I still however would like to know if there is a way to modify a field by accessing a table this way instead of using a recordset.
 

Users who are viewing this thread

Back
Top Bottom