为什么VB用Adodc和DataGrid和Text时,text会自动清空数据

来源:百度知道 编辑:UC知道 时间:2024/05/27 07:11:38
为什么VB用AdoDc和DataGrid和Text时,text会自动清空数据
悬赏分:0 - 离问题结束还有 14 天 22 小时
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
End Sub

有两个Text,点了这个那个Text没内容,点了哪个这个没内容,怎么回事??
Dim myCon As New ADODB.Connection
Dim myRec As New ADODB.Recordset
Dim myCom As New ADODB.Command
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Or Text14.Text = "" Then
MsgBox "笔添信息没有添完,请输入完全", vbOKOnly + vbExclamation, "提示"
Else
Adodc1.Recordset.AddNew
End If
Private Sub Form_Load()
Text2.Visible = False
Label17.Visible = False
Set myCon = New ADODB.Connection
myCon.CursorLocation = adUseClient
lujing = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\新建 Microsoft Office Access 应用程序.mdb"
myC

仔细看了你的代码,连接数据库使用了ADO数据对象和ADO数据控件。代码中存在冲突。
如果使用Adodc1控件,那么TEXTBOX估计你采用了数据绑定,所以执行下列代码:
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
End Sub
Adodc1连接的数据集自动移到新行,等待输入,所以TEXTBOX成空白。
楼上分析的也有可能。

不是Command1和Form_Load的问题
是你的那两个text的问题
它下面一定有代码