VB6.0不同的form连接统一个数据库的问题,请大神解决。

错误为子程序或函数中的属性无效

form1中:
Public j As Integer
Private Sub Form1_Load()
Public cnn As New ADODB.Connection
Public rs As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "E\VB工程\access\tycs.MDB"
rs.Open "select * from YJCS", cnn, adOpenKeyset, adLockOptimistic
Set MSHFlexGrid1.DataSource = rs
MSHFlexGrid.colWidth(0) = 100
'i = 1 '第一个原件编号
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

xnow = X: ynow = Y
If moveflag = True Then
   Dim cnn As New ADODB.Connection
   Dim rs As New ADODB.Recordset
   cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\access\tycs.mdb"
   rs.Open "select * from YJCS where 编号=" & j, cnn, adOpenKeyset, adLockOptimistic
   xnow = rs.Fields("X1")
   ynow = rs.Fields("Y1")
   'xz = rs.Fields("XZFLAG")
   x2 = X: y2 = Y
   rs.Fields("X1") = xnow + x2 - x1
   rs.Fields("Y1") = ynow + y2 - y1
   'If xz = False Then
   rs.Fields("XLEFT") = xnow + x2 - x1
   rs.Fields("YLEFT") = ynow + y2 - y1 - 100
   rs.Fields("YRIGHT") = ynow + y2 - y1 + 100
   rs.Fields("XRIGHT") = xnow + x2 - x1 + 1300
   'Else
   'rs.Fields("XLEFT") = xnow + x2 - x1 - 100
  ' rs.Fields("YLEFT") = ynow + y2 - y1
  ' rs.Fields("YRIGHT") = ynow + y2 - y1 + 1300
   'rs.Fields("XRIGHT") = xnow + x2 - x1 + 100
   'End If
   x1 = x2: y1 = y2
   rs.Update
   rs.Close
   Picture1.Cls
   Call updata
End If

End Sub

form2中
Public j As Integer
Private Sub Command1_Click()
Public cnn As New ADODB.Connection(调试错误指示位置)
Public rs As New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\access\tycs.mdb"
rs.Open "select * from YJCS where 编号=" & j, cnn, adOpenKeyset, adLockOptimistic
If rs.EOF = False Then
rs.Fields("额定容量") = Form2.Text1.Text
rs.Fields("额定频率") = Form2.Text2.Text
rs.Fields("高压侧电压") = Form2.Text3.Text
rs.Fields("低压侧电压") = Form2.Text4.Text
rs.Fields("一次额定电流") = Form2.Text5.Text
rs.Fields("二次额定电流") = Form2.Text6.Text
rs.Fields("名称") = Form2.Text7.Text
rs.Fields("二次额定电流") = Form2.Text8.Text
rs.Fields("空载损耗") = Form2.Text11.Text
rs.Fields("短路电压百分比") = Form2.Text12.Text
rs.Fields("短路损耗") = Form2.Text13.Text
rs.Fields("空载电流百分比") = Form2.Text14.Text
rs.Fields("额定容量") = Form2.Text1.Text
rs.Update
rs.Close
End Sub

2个回答

Form2.Text1.Text
这种代码,能找到另一个窗口么?
看着都悬。哪有这样胡乱写程序的。

sinat_26793923
sinat_26793923 那是在第二个表格中的,有没有在第一个form中调用。
大约 5 年之前 回复

那是在第二个表格中的,有没有在第一个form中调用。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐