使用组合框值插入或更新记录

问题描述

我有一个带有自动填充的时间字段和日期字段的表单。我还有一个组合框,允许用户选择他们正在处理的项目。除了不会从组合框中插入值之外,我可以使所有工作正常进行。 任何建议将不胜感激。

如果表单代码如下:

私人Sub cmdConfirm_Click()

Dim strsql As String

If Me.OpenArgs = "ClockIn" Then
    strsql = "INSERT INTO TimeLog(EmployeeID,WorkDate,TimeStart,Project) " & _
        "VALUES(" & Forms("frmlogin").cboEmployee & _
        ",#" & Format(Me.txtDate,"yyyy-mm-dd") & "#" & _
        ",#" & Format(Me.txtTime,"hh:nn:ss") & "#" & _
        ",& [Forms}![frmTimeClock]![cboProject] & )"
                    
       CurrentDb.Execute strsql,dbFailOnError

Else
    strsql = "UPDATE TimeLog " & _
        "SET TimeEnd = #" & Format(Me.txtTime,"hh:nn:ss") & "# " & _
        "WHERE EmployeeID = " & Forms("frmlogin").cboEmployee & _
        " AND TimeEnd IS NULL"
        
    CurrentDb.Execute strsql,dbFailOnError

End If

If Me.OpenArgs = "ClockIn" Then
    strsql = "UPDATE TimeLog " & _
        "SET Project = [frmTimeClock]![cboProject] & "
End If


DoCmd.Close acForm,"frmlogin"
DoCmd.Close acForm,Me.Name
Forms("frmOpen").Visible = True

结束子

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)