English 中文(简体)
Access: editing a field that is bound to an expression rather than a field
原标题:
  • 时间:2009-11-09 16:26:18
  •  标签:
  • ms-access

On a continouos form in ms-access, I have a record source similar to

select
  col_1,
  col_2 & " " & col_3 as col_expr
from
  tblFoo

and then I have bound col_expr to a text box on that form.

When I open the form, it displays the value of col_2 & " " & col_3 correctly in the textbox. Obviously, editing the value within the text box doesn t work because its value is derived from an expression rather than from a field in the table. Accordingly, access prohibits me from doing so: when I click into the field, I cannot alter anything in the field.

I understand that behaviour. Yet, I am looking for a method to override that behaviour. That is, I want to be able to enter a value into that field and (for example) in its BeforeUpdate event retrieve the entered value and do a custom-insert/update and then set cancel to true.

Is this possible?

最佳回答

It may suit to use a work around, for example, display a hidden textbox for the update and dynamically rewrite the sql using the new data.

EDIT re Comment Alternatively you could show a small form for editing any record in the continuous form.

问题回答

You could fire off an update query on the “After Update” event of that text box. After validating the data of course.





相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

access query to filter and combine count

i have two access tables tableA num count 1 7 2 8 3 9 4 9 5 13 6 6 tableB num count 0 1 1 14 2 12 3 5 4 5 5 11 6 5 how can i create an access query that ...

How to show File Picker dialog in Access 2007?

I want to show a dialog where the user can pick a file, click OK, and then the path to the file will be saved in the database. I have just one problem, I can t figure out how tho show the dialog ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

Returning row number on MS Access

I have 4 tables, from which i select data with help of joins in select query...I want a serial no.(row number) per record as they are fetched. first fetched record should be 1, next 2 and so on... In ...

热门标签