Office中国论坛/Access中国论坛

标题: 关于程序之间的参数传递 [打印本页]

作者: sisound    时间: 2006-12-9 22:56
标题: 关于程序之间的参数传递
Private Sub Image21_Click()
Dim a As String
Dim STemp As String
Dim d As String
Dim e As String
Dim path As String
Dim c As String
Dim rs As ADODB.Recordset
'为定义的数据集变量分配空间
Set rs = New ADODB.Recordset
'为打开数据表“查询语句”字符变量赋值
a = InputBox("请输入五位数的单号,例如61002, 产品型号不用输入", "输入单号")
STemp = "Select * From 投料单明细 where 单号=" & a & ";"
rs.Open STemp, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
If rs.RecordCount = 0 Then
MsgBox "单号输入错误,或者投料单还未输入!"
Else
d = rs("单号")
e = rs("型号")
c = Mid(d, 2, 2)
path = "E:\MIS\投料单\06年投料单\" & c & "月份\QO" & d & e & ".xls"

这里的path得到正确的值以后,我就想直接执行以下的程序,即把path所代表的文件打开,主要是一个shell



Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

ShellExecute 0, "Open", path, "", "", 5


但是我不能直接放在这里,因为事先要声明,我不知道正确的格式,请问谁能告诉我?谢谢

End If
End Sub

作者: andymark    时间: 2006-12-9 23:54
把下面的引用放在程序开始的最上面

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
作者: sisound    时间: 2006-12-10 00:10
不行,我这样试过了,

我复制上去以后,这段代码就自动与本程序分开,跑到上面的一个程序的最后面去了

然后就有提示,"end后面不能有内容~~~"
作者: andymark    时间: 2006-12-10 00:14
把例子传上来
作者: sisound    时间: 2006-12-10 00:30
谢谢斑竹,已经搞定了!!

你真强

不过我还有一个问题

有时候自动生成的路径并不一定对应本地的文件,通过shell去打开的时候一点反应都没有

我想知道是否可以在无法打开的时候给出提示呢?



还有,为什么我做的数据库这么大,刚才看了一下120多M

吓死人了~~


作者: andymark    时间: 2006-12-10 00:34
这是ACCESS的通病,压缩一下应该好很多

  
作者: sisound    时间: 2006-12-10 01:03
谢谢

那前面一个问题我该如何解决呢?
作者: fan0217    时间: 2006-12-11 04:02
以下是引用sisound在2006-12-9 16:30:00的发言:


谢谢斑竹,已经搞定了!!

你真强

不过我还有一个问题

有时候自动生成的路径并不一定对应本地的文件,通过shell去打开的时候一点反应都没有

我想知道是否可以在无法打开的时候给出提示呢?

还有,为什么我做的数据库这么大,刚才看了一下120多M

吓死人了~~







根据返回值(Long)来判断就可以了 ,打开了应该是个非0的值。
作者: sisound    时间: 2006-12-11 18:37
我刚才试了一下,如果打不开的话,返回的参数值为2~~




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3