form1中的代码
Private Sub 货物编号_Click()
If 货物编号.Locked Then Exit Sub
On Error Resume Next
Dim sel As New 数据选择
Dim sql As String
Set sel = New 数据选择
sql = "select 编号,货物名称,货物类别,货物规格 from 货物信息"
sel.Adodc1.ConnectionString = conn.ConnectionString
sel.Adodc1.CommandType = adCmdText
sel.Adodc1.RecordSource = sql
sel.Adodc1.Refresh
title = "请选择入库货物"
sel.Show vbModal
If result1 <> "" Then
货物编号.Text = result1
End Sub
form2的代码
Option Explicit
Private Sub CancelButton_Click()
result1 = ""
result2 = ""
Unload Me
End Sub
Private Sub OKButton_Click()
On Error Resume Next
result1 = DataGrid1.Columns(0).Text
result2 = DataGrid1.Columns(1).Text
Unload Me
Exit Sub
End Sub
Private Sub Form_Load()
Adodc1.Visible = False
End Sub
Private Sub Form_Resize()
On Error Resume Next
Adodc1.ConnectionString = conn.ConnectionString
Set DataGrid1.DataSource = Adodc1
Adodc1.Refresh
Me.caption = title
Dim d As Integer
If DataGrid1.Columns.Count <= 2 Then
d = 600
Else
d = 50
End If
Dim i As Integer
For i = 0 To DataGrid1.Columns.Count - 1
DataGrid1.Columns(i).Width = Len(DataGrid1.Columns(i).caption) * d
Next
我想这么做,但是不对