Updating a field of an Access table with data from form

帅比萌擦擦* 提交于 2019-12-24 22:15:53

问题


I am working on Access 2007. I have a table with some fields in it. I had created a form from the table and one of the fields of the table is a concatenation of 2 fields from the same table.

There are 2 fields OppNo and Material in the table. I had created a form with these (and others in the table) fields. There is another field OppMat which is blank in the table. However, I had got the data into OppMat field populated as a concatenation of OppNo and Material fields in the form. I am now looking at having the table updated with the data of OppMat from the form to the same corresponding field in the table.

Kindly advise as how I could achieve this.

Thanks and regards,


回答1:


This might be possible if these cases are met:

  • The field OppMat ALWAYS has the same structure and you can assure that it does.
  • Users will not be able or very unlikely to deviate from this structure.

Notably you should use something like Left(), Right(), Mid() and so on. Whatever works best for your structure. You can use the string modifiers: https://msdn.microsoft.com/en-us/library/dd789093.aspx

On the other hand I must admit that I am sceptical if your solutions is the best. Here are my reasons:

  • Users are unpredictable and will continously deviate from your intended way to use the application.
  • Using the string functions and fixating on one structure makes your code construction inflexible, hard to maintain if changes occur and prone to errors.
  • The alternatives seem to be better with little drawback.

My suggestions for alternatives:

  • Use one textbox for each field so that you have two textboxes. You can even position them that way that it almost looks like it is continous text. But not too much otherwise the user will beconfused.
  • You can add a label that shows your concatenated fields. But for input you use two different textboxes.

Cheers!



来源:https://stackoverflow.com/questions/29553492/updating-a-field-of-an-access-table-with-data-from-form

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!