请参考这张图片:
所以,我为11台机器制作了一个包含11x3文本框的表单。一台机器有3个参数文本框。
我的表名为TOSA_settings,字段如下: UCL LCL 意思 机
我已经禁用了所有文本框,因为用户应该能够编辑/更新他们只想更新的任何机器。如果用户想要更新机器1,他将点击TOSA 01文本框右侧的编辑标签,文本框将被启用= true。用户可以填写数据,然后仅保存该特定计算机。其余的将保持禁用状态。
现在,我只尝试编码两台机器,看它是否有效。
因此,我在cmdSave_Click()下编写代码
Dim strSQL As String
If mean1.Value <> "" Then
strSQL = "INSERT INTO TOSA_settings( UCL, LCL, mean, machine) VALUES (" & Me.UCL1 & "," & Me.LCL1 & ", " & Me.mean1 & ", 'TOSA 01');"
End If
If mean2.Value <> "" Then
strSQL = "INSERT INTO TOSA_settings( UCL, LCL, mean, machine) VALUES (" & Me.UCL2 & "," & Me.LCL2 & ", " & Me.mean2 & ", 'TOSA 02');"
End If
CurrentDb.Execute strSQL, dbFailOnEror
但它只保存了TOSA 02中的值。还是应该创建其他表,每台一台?
您将必须执行两次(或多次):
Dim strSQL As String
If mean1.Value <> "" Then
strSQL = "INSERT INTO TOSA_settings( UCL, LCL, mean, machine) VALUES (" & Me.UCL1 & "," & Me.LCL1 & ", " & Me.mean1 & ", 'TOSA 01');"
CurrentDb.Execute strSQL, dbFailOnEror
End If
If mean2.Value <> "" Then
strSQL = "INSERT INTO TOSA_settings( UCL, LCL, mean, machine) VALUES (" & Me.UCL2 & "," & Me.LCL2 & ", " & Me.mean2 & ", 'TOSA 02');"
CurrentDb.Execute strSQL, dbFailOnEror
End If