|
Question : API Function Syntax Error
|
|
Good Morning,
I have been trying to program Express ClickYes to operate from an autoexec macro. The autoexec macro calls each of the API Functions Shown on the ClickYes Web Page, then the macro opens a form called 'friday'. The OnOpen event of the 'friday' form is intended to run the DoCmd.SendObject command for however many recipients in test table (the control source for the 'friday' form) .
The macro bails right at the first API function Declaration. I have tried deleting each of the function declarations individually, to see which one was the culprit and it doesn't amke any diference - they all cause the code to crash.
I appreciate any assistance you can provide.
Thank-you
aasikolo
Option Compare Database Private Declare Function RegisterWindowMessage _ Lib "User32" Alias "RegisterWindowMessageA" _ (ByVal lpString As String) As Long
Private Declare Function Findwindow Lib "User32" _ Alias "FindWindowA" (ByVal lpClassName As Any, _ ByVal lpWindowName As Any) As Long
Private Declare Function SendMessage Lib "User32" _ Alias "SendMessageA" (ByVal hwnd As Long, _ ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long
Private Sub tryagain() Dim wnd As Long Dim uclickYes As Long Dim Res As Long Dim rs As DAO.Recordset Dim bigmess As String
uclickYes = RegisterWindowMessage(clickyes_suspend_resume) wnd = Findwindow(exclickyes_wnd, 0&) Res = SendMessage(wnd, uclickYes, 1, 0)
Set rs = CurrentDb.OpenRecordset("testtable") 'DoCmd.OpenForm "friday" 'DoCmd.Minimize bigmess = "" & [Forms]![friday]![stremp_name] & ":" & vbCrLf & " " & [Forms]![friday]![PARNums] & " Approval PAR(s) have just been received from " & [Forms]![friday]![co_name] & vbCrLf & "Please view the attachment for more information, and utilize the flag database if necessary." & vbCrLf & "Thank-you" rs.MoveFirst Do Until rs.EOF DoCmd.SendObject acReport, "lastflagqryreport", "SnapshotFormat(*.snp)", [Forms]![friday]![QAD EMP Email], , , " Incoming PAR(s) From Company Under Investigation", bigmess, False, """" rs.MoveNext Loop Set rs = Nothing Res = SendMessage(wnd, uclickYes, 0, 0) DoCmd.SetWarnings (yes) Exit Sub End Sub
|
|
Answer : API Function Syntax Error
|
|
turn the sub procedure tryagain into a public function, otherwise i don't think you can call it from a macro as for the declaration functions, it doesn't matter if they are private or public if you're not calling them from the macro
Public Function tryagain() Dim wnd As Long Dim uclickYes As Long Dim Res As Long etc... . . . DoCmd.SetWarnings (yes) Exit Function End Function
and call tryagain from the autoexec macro instead
|
|
|
|