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
Vb.net 我想要的代码将搜索文件是否存在,如果它存在,那么它将打开该记录,否则它将创建新的_Vb.net_Ms Access - Fatal编程技术网

Vb.net 我想要的代码将搜索文件是否存在,如果它存在,那么它将打开该记录,否则它将创建新的

Vb.net 我想要的代码将搜索文件是否存在,如果它存在,那么它将打开该记录,否则它将创建新的,vb.net,ms-access,Vb.net,Ms Access,我不熟悉编码。我在VB.net中用MS access中的数据库创建了一个程序 我想做一个文本框,既可以作为搜索栏,也可以添加新的内容。当用户输入文本并移动到下一个文本框时,该函数将搜索,如果该程序编号存在,它将显示该记录,否则它将创建新记录。 此代码的问题在于,在添加新记录时,它会更改上次打开记录的程序号。 这是密码 Private Sub progno_enterpress(sender As Object, e As EventArgs) Handles progno.LostFocus

我不熟悉编码。我在VB.net中用MS access中的数据库创建了一个程序 我想做一个文本框,既可以作为搜索栏,也可以添加新的内容。当用户输入文本并移动到下一个文本框时,该函数将搜索,如果该程序编号存在,它将显示该记录,否则它将创建新记录。 此代码的问题在于,在添加新记录时,它会更改上次打开记录的程序号。 这是密码

Private Sub progno_enterpress(sender As Object, e As EventArgs) Handles progno.LostFocus

    prgnum = progno.Text
    If progno.Text = "" Then
        Call notfound()
        Exit Sub

    Else
        Table1BindingSource.Filter = "(Prgno Like '" & prgnum & "')"
        If Table1BindingSource.Count <> 0 Then

                With DataGridView1
                    .DataSource = Table1BindingSource
                End With

                Table1BindingSource.EndEdit()
            Exit Sub
        Else
            Table1BindingSource.Filter = Nothing
            Table1BindingSource.AddNew()
            Exit Sub
        End If
Private Sub progno\u enterpress(发送方作为对象,e作为事件参数)处理progno.LostFocus
prgnum=progno.Text
如果progno.Text=”“,则
调用notfound()
出口接头
其他的
Table1BindingSource.Filter=“(类似Prgno的“&prgnum&”)”
如果Table1BindingSource.Count为0,则
使用DataGridView1
.DataSource=表1绑定源
以
表1BindingSource.EndEdit()
出口接头
其他的
表1BindingSource.Filter=无
表1BindingSource.AddNew()
出口接头
如果结束

如果这是Access中的VBA,我会首先移动到表单上的新记录,并使用textbox BeforeUpdate事件验证输入。我可能也会使用组合框而不是文本框。如果这是Access中的VBA,我会首先移动到表单上的新记录,并使用textbox BeforeUpdate事件来验证输入。我也可能使用组合框而不是文本框。