绑定表单 - 根据键值插入或更新? [英] Bound form - insert or update based on key value?

查看:45
本文介绍了绑定表单 - 根据键值插入或更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于任何有基本形式经验的人来说,这应该是一个简单的方法(我讨厌让你们觉得无聊!):D


我有一个简单的形式,绑定单个表格。

我会*喜欢*以这种方式工作的表单:

  • 表单应该打开并且全部为空。
  • 如果用户选择作业订单号,控制并选择现有的作业单号,表单上的所有控件都将定位到该作业单。

    当用户操作其他表单控件中的数据时,现有的作业顺序记录会更新。
  • 如果用户而不是键入新作业订单号,并将数据输入/选择到其他控件中,这将作为新的作业订单记录插入到表中。
  • This should be an easy one for anyone with basic forms experience (I''d hate for you guys to be bored!) :D

    I have a simple form, bound to a single table.

    I''d *like* the form to work this way:

    • The form should open and be all blank.
    • If the user selects the "Job Order Number" control and picks an existing Job Order Number, all the controls on the form will position to that job order.
      When the user manipulates the data in other form controls, the existing Job Order record is updated.
    • If the user instead types in a new Job Order Number, and inputs/selects data into the other controls, this is inserted as a new Job Order record into the table.
    • 推荐答案

      在你的表格'模块中你会发现一些代码类似于:
      In your form''s module you will find some code similar to :
      展开 | 选择 | Wrap | 行号


      是的 - 我对第一段代码很熟悉 - 我相信该代码在OnChange中存在(或由其触发)。用于控制键值的事件,选择要显示的其他控件的记录?


      只有我有点困惑(并且我确定我''我会发现因为我现在要试试这个!),这是否意味着表格会打开定位到所有空白?


      出于某种原因,我今天早上打开了我的笔记本电脑,打开了数据库,打开了表格......所有控件显示空白。

      中途那里?

      好​​吧,没有 - 我输入了一个新字母。记录,点击---> (表单保存记录按钮),我收到错误 - 主键不允许空值这一行。我觉得这很奇怪,因为我在组合框中键入了一个新值 - 但是我看到你发布的内容中有一些代码,听起来它或多或少实际上允许插入新记录?


      谢谢你 - 我会告诉你发生了什么!
      Yes - I''m familiar with that first snippet of code, somewhat - i believe that code exists (or is triggered by, rather) in the "OnChange" event for the control on the key value that selects the record for the other controls to display?

      Only thing I''m slightly confused by (and I''m sure I''ll find out because of course I''m going to give this a try right now!), is whether that means the form will open up positioned to "all blanks"?

      For some reason, I opened my laptop this morning, opened the database, opened the form... and all the controls showed blanks.
      Halfway there?
      Well, no - I input a "new" record, hit "--->" (a form "save record" button), and I got an error - something along the lines of "null values are not allowed for the primary key". I thought that was strange since I typed a new value into that combobox - but I see there''s some code in what you posted that sounds like it more or less actually allows for a new record to be inserted?

      Thanks for that - I''ll let you know what happens!


      没关系。


      代码特别处理Null值,而不是试图通过现有的逻辑推送它(就像以前一样)。


      让我们知道你是如何继续的,但它肯定应该去到新记录;)
      It sould be fine.

      The code handles an Null value specially, rather than trying to push it through the existing logic (as it was doing previously).

      Let us know how you get on, but it should certainly go to the New record ;)


      这篇关于绑定表单 - 根据键值插入或更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆