将复选框与SQL Server链接表中的位列绑定 [英] bind checkbox with a bit column in a SQL Server linked table

查看:82
本文介绍了将复选框与SQL Server链接表中的位列绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将复选框与SQL Server链接表中的bit列绑定.

I'm trying to bind a checkbox with a bit column in a SQL Server linked table.

首先,我对类型有一个错误,然后我进入了访问权限的链接表,并将该列的显示控件更改为复选框而不是文本框.

I had an error about the type at first, then I went in my linked table in access and changed the display control of the column to checkbox instead of textbox.

现在保存记录时出现写冲突错误.

Now I have a write conflict error when I save the record.

我尝试了有关在表中添加时间戳的解决方案,但遇到了同样的问题

I tried the solution about adding a timestamps in the table but I got the same problem

没有VBA是否有可能?

Is it possible without VBA?

谢谢

我的保存按钮的代码

Private Sub btnSave_Click()
  On Error GoTo Err_btnSave_Click
      DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
      DoCmd.Close
  Exit_btnSave_Click:
      Exit Sub

  Err_btnSave_Click:
      MsgBox Err.Description
      Resume Exit_btnSave_Click

End Sub

我认为那里没有任何问题.只有当复选框绑定到位列时我才收到错误

I don't think there's anything wrong there. I got the error only when there's a checkbox bound to a bit column

我试图将文本框绑定到同一列.默认情况下,该值为false,如果我不更改is值,则不会出现错误.

I tried to bound a textbox to the same column. The value is false by default and I don't have the error if I don't change is value.

但是当表单很脏时,即使我更改另一个控件的值,也会出现错误.

but when the form is dirty, even if I change the value of an another control, I got the error.

我不明白.就像Access不了解在bit列绑定控件时只有一个用户一样.

I don't understand. It's like if Access doesn't understand that there's only one user when there's a control bound to a bit column.

上次遇到此问题时,我放弃了,我将类型更改为一个小整数,但我很好奇.有没有办法让它变得物有所值.我想要的只是一个布尔值.

The last time I had this problem, I gave up and I change the type for a small int but I'm curious. Is there a way to make it worth with a Bit. all I want is a Boolean.

推荐答案

检查SQL Server中的位字段是否可为空.如果设置为非空,则将SQL Server中的默认值设置为0(假).这里有一个有关可空位字段的问题的讨论:

Check if the bit field in SQL server is nullable. If it is, make it non-null and set the default value in SQL server to 0 (false). There is a discussion of this issue with nullable bit fields here: Nullable bool fields in MS Access linked tables

这篇关于将复选框与SQL Server链接表中的位列绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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