使用Ms Access窗体,旨在以数据表模式显示,以允许一次查看和添加多行数据。
一旦用户将他们的数据输入表格,我有一个按钮,他们必须在离开表格之前点击。我希望按钮在运行宏之前验证选项1或2是否为真,否则消息框会提示用户。
@import "bootstrap-sprockets";
@import "bootstrap";
@import "font-awesome-sprockets";
@import "font-awesome";
@import "bootstrap-slider";
@import "addresses.scss";
@import "articles.css.scss";
@import "common.css.scss";
@import "footer.css.scss";
@import "forms.css.scss";
@import "glyphs.css.scss";
@import "index.css.scss";
@import "legal.css.scss";
@import "navigation.css.scss";
@import "pages.css.scss";
@import "profiles.scss";
@import "video.css.scss";
不为空。LPymtDate
或MdID
或AdmitDt
或DischrgDt
)下面是我一直在使用的代码,但它只检查一行数据。有没有人有建议或代码可以让我验证所有行?
LPymtDate
答案 0 :(得分:0)
用户在保存之前验证每一行会更简单也更好 - 而且不需要任何按钮。
为此,请使用以下格式的BeforeUpdate事件:
Cancel = IsNull([Eps] & [Clm#]) Or IsNull([LPymtDate] + [MdID] + [AdmitDt] + [DischrgDt] + [LPymtDate])
If Cancel = True Then
MsgBox "Please input required fields."
Else
DoCmd.RunMacro ("CheckingAccts")
End If
答案 1 :(得分:0)
Option Compare Database
Private Sub Command12_Click()
Dim myConnection As ADODB.Connection
Set myConnection = CurrentProject.Connection
Dim myRecordset As New ADODB.Recordset
Dim f As Integer
Dim ans As Integer
Set rst = myRecordset
myRecordset.ActiveConnection = myConnection
myRecordset.Open "Local_Holder_CoverInfo_3_Accounts", , adOpenStatic, adLockOptimistic
rst.MoveFirst
Do Until rst.EOF()
If (Not IsNull([Eps]) Or Not IsNull([Clm#])) And Not IsNull([LPymtDate]) Then
DoCmd.GoToRecord , , acNext
ElseIf Not IsNull([MedID]) And Not IsNull([AdmitDt]) And Not IsNull([DischrgDt]) And Not IsNull([LPymtDate]) Then
DoCmd.GoToRecord , , acNext
Else
f = 1
End If
rst.MoveNext
Loop
If f >= 1 Then
MsgBox "Input Required Fields"
Else
DoCmd.RunMacro ("CheckingAccts")
End If
End Sub