在线等,怎么调用不到?
在frmSUM中.我想调用frmdatamanage中的displaygrid1,提示未找到方法和数据成员.
frmSUM中的程序:
On Error GoTo cmderror
Dim find_date1 As String
Dim find_date2 As String
find_date1 = Format(CDate(cmbyear.Text & "- " & _
cmbmouth.Text & "- " & cmbday.Text), "yyyy-mm-dd ")
find_date2 = Format(CDate(cmbyear1.Text & "- " & _
cmbmouth1.Text & "- " & cmbday1.Text), "yyyy-mm-dd ")
sqlfind = "select * from information where in_time between # " & _
find_date1 & "# " & " and " & " # " & find_date2 & "# "
rs_data1.Open sqlfind, conn, adOpenKeyset, adLockPessimistic
frmdatamanage.displaygrid1
Unload Me
cmderror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
frmdatamanage中的程序
Private Sub Form_Load()
On Error GoTo loaderror
Dim sql As String
displaygrid1
loaderror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
Public Sub displaygrid1()
Dim i As Integer
On Error GoTo displayerror
setgrid
setgridhead
MSFlexGrid1.Row = 0
If Not rs_data1.EOF Then
rs_data1.MoveFirst
Do While Not rs_data1.EOF
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
MSFlexGrid1.Col = 0
If Not IsNull(rs_data1.Fields(0)) Then MSFlexGrid1.Text = rs_data1.Fields(0) Else MSFlexGrid1.Text = " "
MSFlexGrid1.Col = 1
If Not IsNull(rs_data1.Fields(1)) Then MSFlexGrid1.Text = rs_data1.Fields(1) Else MSFlexGrid1.Text = " "
MSFlexGrid1.Col = 2
If Not IsNull(rs_data1.Fields(2)) Then MSFlexGrid1.Text = rs_data1.Fields(2) Else MSFlexGrid1.Text = " "
MSFlexGrid1.Col = 3
If Not IsNull(rs_data1.Fields(3)) Then MSFlexGrid1.Text = rs_data1.Fields(3) Else MSFlexGrid1.Text = " "
MSFlexGrid1.Col = 4
If Not IsNull(rs_data1.Fields(4)) Then MSFlexGrid1.Text = rs_data1.Fields(4) Else MSFlexGrid1.Text = " "
MSFlexGrid1.Col = 5
If Not IsNull(rs_data1.Fields(5)) Then MSFlexGrid1.Text = rs_data1.Fields(5) Else MSFlexGrid1.Text = " "
'MSFlexGrid1.Col = 6
'If rs_data1.Fields(6) = True Then MSFlexGrid1.Text = "进库 " Else MSFlexGrid1.Text = "出库 "
rs_data1.MoveNext
Loop
End If
displayerror:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub
[解决办法]
你没有在任何位置告诉VB要显示这个窗体,当然不会显示了
你可以在displaygrid1里的最后一句写me.show 1
也可以在frmdatamanage.displaygrid1的后面写frmdatamanage.show 1