|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
今天遇到一个奇怪的问题。当我在一个窗体里点击命令按钮打开另一个窗体,并试图给另一个窗体的某个文本框赋值的时候系统说 Method 'item' of Object 'Forms' Failed.
但是我检查了半天也不知道为什么。因为在其他窗体我有同样的代码是可以工作的。有人遇到过这个问题吗?以下是代码:
Private Sub cmdViewSample_Click()
Dim sql As String
Dim MyForm As Form
Dim tempCtrl, tempStyle, temp As String
Dim tblBatch, tblCourier, tblStatus, tblComments, tblMerchandiser As String
Dim tblSendDate, tblReceiveDate, tblStatusDate As Date
tempCtrl = Forms!frmOrderPeru.Control_Number.Value
tempStyle = Forms!frmOrderPeru.subfrmOrderDetailsSoftPeru.Form!Style.Value
Dim Cnn As ADODB.Connection
Dim Rst As ADODB.Recordset
Dim Rsql As String
Set Cnn = New ADODB.Connection
Set Rst = New ADODB.Recordset
Cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= Y:\Cencosud Projects and Order Follow Up.mdb"
Rst.Open "select top 1 iif(isnull([Sample Batch]),0,[Sample Batch]) from tblSampleLabdip Where [Control Number]= '" & tempCtrl & "' And [Style]= '" & tempStyle & "'", Cnn, adOpenKeyset, adLockOptimistic, adCmdText
tblBatch = Rst.Fields(0)
Set Rst = Nothing: Set Cnn = Nothing
DoCmd.OpenForm FormName:="frmSoftPeruSampleStatus"
Forms!frmSoftPeruSampleStatus.SetFocus - 执行到这里出现提示错误。
Forms!frmSoftPeruSampleStatus.txtLabdipBatch = tblBatch |
|