vbs 传递参数奇怪的行为 [英] vbs passing parameters weird behavior

查看:23
本文介绍了vbs 传递参数奇怪的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个应该打开访问的 .vbs 文件,并在内部访问一个表单调用问题详细信息",但传递了一个参数,这意味着如果我的问题"表中有 10 个问题,则会创建一个 vbs 文件每一个,当点击时应该打开正确的记录(表中的每条记录都是一个 ID).到目前为止,它正在打开访问并打开表单(问题详细信息),但它是空白的.我错过了什么?帮助,在这里发疯......检查下面的代码.这里奇怪的是,如果我再次双击它,它将刷新并打开正确的记录,而无需再打开窗口.我该如何解决?我不想做两次:)

i am creating a .vbs file that should open access, and inside access a form call "Issue Details", but passing a parameter, meaning that if i have 10 issues in my "Issues" table a vbs file is created for each one and when clicked should open the right record(would be one ID for each record in the table). It is so far opening access and it is opening the form(Issue Details) but it is blank. What am i missing? Help, getting crazy here ... Check code below. The weird thing here is that if i double click it again it will refresh and open the right record without opening anymore windows.. How can i fix that? I dont want to do it twice :)

Public Sub sendMRBmail(mrbid)
DoCmd.OpenForm "Issue Details", , , "[ID] = " & mrbid
End Sub

Private Sub Create_Click()
On Error GoTo Err_Command48_Click
Dim snid As Integer
snid = Me.ID
Dim filename As String
filename = "S:\Quality Control\vbs\QC" & snid & ".vbs" 
Dim proc As String
proc = Chr(34) & "sendMRBmail" & Chr(34)

Dim strList As String

strList = "On Error Resume Next" & vbNewLine
strList = strList & "dim accessApp" & vbNewLine
strList = strList & "set accessApp = createObject(" & Chr(34) & "Access.Application" & Chr  (34)")" & vbNewLine
strList = strList & "accessApp.OpenCurrentDataBase(" & Chr(34) & "S:\Quality Control\Quality  DB\Quality Database.accdb" & Chr(34) & ")" & vbNewLine
strList = strList & "accessApp.Run " & proc & "," & Chr(34) & snid & Chr(34) & vbNewLine
strList = strList & "set accessApp = nothing" & vbNewLine
Open filename For Output As #1
Print #1, strList
Close #1

Err_Command48_Click:

If Err.Number <> 0 Then
 MsgBox "Email Error #: " & Err.Number & ", " & "Description: " & Err.Description
  Exit Sub
End If
End Sub

推荐答案

发现问题.更改了下面的说明,向其中添加了 acFormEdit 并且它起作用了:

Found the problem. Changed instruction below, adding acFormEdit to it and it worked:

DoCmd.OpenForm "Issue Details", , , "[ID] = " & mrbid, acFormEdit

这篇关于vbs 传递参数奇怪的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆