我正在尝试创建一个Access宏,只有在从表中检索特定值时才会运行。我试图阻止用户每个周期多次运行宏。
If sqlquery = "select Step 3 from XX_STORE_VALUE" = "READY" Then
DoCmd.SetWarnings (warningsoff)
DoCmd.OpenQuery "00 UPDATE NEXT NR AND LD ACCRUAL", acViewNormal, acEdit
DoCmd.OpenQuery "00 UPDATE NEXT NR AND LD SALES", acViewNormal, acEdit
DoCmd.OpenQuery "UPDATE STEP 3", acViewNormal, acEdit
DoCmd.SetWarnings (warningson)
End If
End Function
答案 0 :(得分:0)
您可以尝试这样的事情
Public Function GetQueryreturnedvalue(yourvalue As Integer)
Dim rst As DAO.Recordset
Dim strSQL As String
' Getting value from your query
strSQL = "SELECT [Step 3] FROM XX_STORE_VALUE where yourcriteria = " & yourvalue & ""
Set rst = CurrentDb.OpenRecordset(strSQL)
GetQueryreturnedvalue = rst![Step 3]
If GetQueryreturnedvalue = "Yourspecificvalue" Then
DoCmd.SetWarnings (warningsoff)
DoCmd.OpenQuery "00 UPDATE NEXT NR AND LD ACCRUAL", acViewNormal, acEdit
DoCmd.OpenQuery "00 UPDATE NEXT NR AND LD SALES", acViewNormal, acEdit
DoCmd.OpenQuery "UPDATE STEP 3", acViewNormal, acEdit
DoCmd.SetWarnings (warningson)
rst.Close
Set rst = Nothing
End If
End Function