怎么使下面这段代码与form9里的text1文本框联系起来。让text1里的数据添加到下面里面去?
Private Sub Command6_Click()
Form9.Show vbModal    If mrc.RecordCount > 0 Then
        Dim pName As String
        pName = mrc.Fields("inputp").Value
        mrc.Open SQL, dbconn, adOpenStatic, adLockOptimistic
        SQL = "select * from testdes where inputp"
            If mrc.RecordCount > 0 Then
                mrc.AddNew
                mrc.Fields("inputp").Value = pName
            End If
        mrc.Update
    End If
    
End Sub

解决方案 »

  1.   

    没明白你的意思,另你贴的这段代码是不是有问题
     If mrc.RecordCount > 0 Then
            Dim pName As String
            pName = mrc.Fields("inputp").Value
            mrc.Open SQL, dbconn, adOpenStatic, adLockOptimistic是不是应该先mrc.close再mrc.open
      

  2.   


    Private Sub Command6_Click()
         dim MyStr as string      Form9.Show vbModal
         MyStr = MyVar       '取得Form9中的 Text1中的文本
        If mrc.RecordCount > 0 Then
            Dim pName As String
            pName = mrc.Fields("inputp").Value
            mrc.Open SQL, dbconn, adOpenStatic, adLockOptimistic
            SQL = "select * from testdes where inputp"
                If mrc.RecordCount > 0 Then
                    mrc.AddNew
                    mrc.Fields("inputp").Value = pName
                End If
            mrc.Update
        End If
        
    End Sub
    'Form9 中添加如下代码
    Private Sub Form_Unload(Cancel As Integer)
            MyVar = Text1.Text
    End Sub'Modules 模块中添加
    Public MyVar As String
      

  3.   

    按你的方法添加了。
    这句
      pName = mrc.Fields("inputp").Value
       但是提示  无效使用 Null
      

  4.   

    你如果要取得form9里text1的数据
    那就在你要的东西=form9.text1.text就可以了
      

  5.   


    Private Sub Command6_Click()
    Form9.Show vbModal    If mrc.RecordCount > 0 Then
           ' Dim pName As String
           ' pName = mrc.Fields("inputp").Value
            mrc.Open SQL, dbconn, adOpenStatic, adLockOptimistic
            SQL = "select * from testdes where inputp"
                If mrc.RecordCount > 0 Then
                    mrc.AddNew
                    mrc.Fields("inputp").Value = Form9.Text1.Text
                End If
            mrc.Update
        End If
        
    End Sub