访问获得焦点时加载记录

时间:2014-10-21 00:50:33

标签: vba ms-access-2007 dde

我已经访问2007作为PLC系统的数据库引擎。我使用RSLinx作为我的DDE。始终加载Access,Batch_Setup形式为Popup,访问最小化。

我要做的是让表单Batch_Setup在每次访问最大化时显示当前批处理信息。我做一个DDE请求来获取当前的Formula_Number,但我无法弄清楚如何使表单转到Formula_Number。

这是VBA代码:

Private Sub Form_Activate()
    Dim BATCH_NAME As String, STRX As String, LOOPX As Integer
    Dim TEMP_X As Integer
    abddeinitiate = DDEInitiate("RSLinx", "GCT")
    BATCH_NAME = DDERequest(abddeinitiate, "BATCH_NAME")

    STRX = 1
    LOOPX = 1
    While Not (STRX = "-")
        STRX = Mid(BATCH_NAME, LOOPX, 1)
        LOOPX = LOOPX + 1
    Wend

    LOOPX = LOOPX - 2
    STRX = Left(BATCH_NAME, LOOPX)
    TEMP_X = MsgBox(STRX, vbOKCancel)
    With Me.Recordset
        .FindFirst "FORMULA_NUMBER = " & CInt(STRX)
    End With

End Sub

我尝试过Activate,GotFocus,Load,....但我无法让它转到当前的批量设置。我可以通过Find找到它,但是我希望它在恢复Access时将其转到,并且Batch_Setup表单始终作为Popup加载。

0 个答案:

没有答案