带数据库链接的小时日志的可编辑数据输入表单

问题描述

再次对此采取行动。通过youtube的非常详尽的分步教程,我对自己想要的东西有了更好的了解,但是在尝试测试表单时,最后仍然收到错误消息。

我的表单正在寻找该零件,但不起作用。提交按钮会将输入的数据发送到数据库,而重置按钮清除输入表单。由于我已经遇到问题,因此尚未触摸“编辑”按钮。

Entry Form

Error Message after run

数据库没有像实际教程中那样向我显示实际数据库中的内容,所以我知道那里也存在问题。我这次发布了模块信息。

调试将我指向这里:

Debug1

这是我从教程中创建的模块(3个子例程),只是不确定是什么问题。我确实有一个尚未编程的cmd按钮(“编辑”),但未对其进行引用,因此我知道这不是问题。想一想它是如何设置show_form或我的iRow变量的……我并没有真正得到这些变量,但是这次尽可能地遵循了说明。

显式选项

Sub Reset()

Dim iRow As Long

iRow = [Counta(Database!A:A)] 'identifies the last row

With frmForm

     .txtID.Value = " "
     .txtName.Value = " "
     .txtCostc.Value = " "
     .txtDept.Value = " "
     .txtPay.Value = " "
     .txtSdate.Value = " "
     .txtSuper.Value = " "
     .optCWS.Value = False
     .optFWS.Value = False
     
     .lstDatabase.ColumnCount = 12
     .lstDatabase.ColumnHeads = True
     
     .lstDatabase.ColumnWidths = "30,60,75,40,45,55,60"
     
    If iRow > 1 Then
    
        .lstDatabase.RowSource = "Database!A2:K" & iRow
    Else
    
        .lstDatabase.RowSource = "Database!A2:K"
        
    End If
        

End With

结束子

Sub Submit()

昏暗作为工作表 昏暗的iRow只要

设置sh = ThisWorkbook.Sheets(“数据库”)

iRow = [Counta(数据库!A:A)] + 1

使用sh

.Cells(iRow,1) = iRow - 1

.Cells(iRow,2) = frmForm.txtID.Value

.Cells(iRow,3) = frmForm.txtName.Value

.Cells(iRow,4) = frmForm.txtSuper.Value

.Cells(iRow,5) = frmForm.txtDept.Value

.Cells(iRow,6) = IIf(frmForm.optFWS.Value,"S09996","S09992")

.Cells(iRow,7) = IIf(frmForm.optCWS.Value,"S09992","S09996")

.Cells(iRow,8) = frmForm.txtCostc.Value

.Cells(iRow,9) = frmForm.txtSdate.Value

.Cells(iRow,10) = frmForm.txtPay.Value

.Cells(iRow,11) = Application.UserName

.Cells(iRow,12) = [Text(Now(),"DD-MM-YYY HH:MM:SS")]

结尾为

结束子

Sub Show_Form()

frmForm.Show

结束子

解决方法

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

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

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