Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access 将记录添加到记录集中后,新记录在子过程中不可用_Ms Access_Vba_Excel - Fatal编程技术网

Ms access 将记录添加到记录集中后,新记录在子过程中不可用

Ms access 将记录添加到记录集中后,新记录在子过程中不可用,ms-access,vba,excel,Ms Access,Vba,Excel,我有一个子过程,将新记录添加到记录集 Dim RS As Recordset Set RS = getRSObject("Tickets") RS.AddNew RS.Fields("subject").Value = Me.txtSubject.Text RS.Fields("detail").Value = Me.txtDetail.Text RS.Fields("dateopen").Value = Format(Now, "mm/dd/yy hh:nn") RS.Fields("stat

我有一个子过程,将新记录添加到记录集

Dim RS As Recordset
Set RS = getRSObject("Tickets")
RS.AddNew
RS.Fields("subject").Value = Me.txtSubject.Text
RS.Fields("detail").Value = Me.txtDetail.Text
RS.Fields("dateopen").Value = Format(Now, "mm/dd/yy hh:nn")
RS.Fields("status").Value = "Open"
RS.Fields("user").Value = Me.ComboUser.Text
RS.Fields("assignedto").Value = Me.comboAssignedTo.Text
RS.Fields("priority").Value = Me.ComboPriority.Text
RS.Fields("category").Value = Me.comboCategory.Text
RS.Fields("unplanned").Value = Me.cbUnplannedWork.Value
RS.Save

RS.Close
doEvents 
我的问题是,在同一模块的下面几行,我通过查询相同的访问表来更新票证列表。但此新记录不在此记录集中。几乎就好像在子过程完成之前,记录不会被写入access

在上述过程完成后,当我看到插入的记录时,我手动刷新票据列表

如果我像“insert into tickets(……”中那样以完整的sql语句运行insert,这很好,并且我在列表中看到了记录,但是如果用户在文本字段中输入诸如连字符之类的字符,则很容易出现问题


有人能给我一个命令,强制将数据写入Access数据库,并在子系统完成之前使其可用。

尝试使用
RS.Update
而不是
RS.Save

Dim RS As Recordset
Set RS = getRSObject("Tickets")
RS.AddNew
RS.Fields("subject").Value = Me.txtSubject.Text
RS.Fields("detail").Value = Me.txtDetail.Text
RS.Fields("dateopen").Value = Format(Now, "mm/dd/yy hh:nn")
RS.Fields("status").Value = "Open"
RS.Fields("user").Value = Me.ComboUser.Text
RS.Fields("assignedto").Value = Me.comboAssignedTo.Text
RS.Fields("priority").Value = Me.ComboPriority.Text
RS.Fields("category").Value = Me.comboCategory.Text
RS.Fields("unplanned").Value = Me.cbUnplannedWork.Value

RS.Update


RS.Close
doEvents 

RS.Update
而不是
RS.Save