Find Message Number of Popup Dialog Text - vba

I don't find the answer on the internet.
When I open some orders in a transaction, I have sometimes a popup. I want to execute some code if this popup text is 'Consider the subsequent documents'. If it is another text, I will execute some other code.
Problem is, we use SAP in several languages (EN, DE, FR), so I can't just say "if text = 'Consider the subsequent documents'. I know each message has its own ID in SAP. I know how to find this ID manually (see screenshot below), but I can't access it with findById(), even using the Record and Playback tool, because it uses the Performance Assistant window, which is not a children of the SAP session (it's a separate application, see second screenshot).
How could I do?
If session.ActiveWindow.Name = "wnd[1]" Then 'There is a popup
'Find message number (haven't find better way)
session.findById("wnd[1]/tbar[0]/btn[1]").press 'Press "Info"
'Line missing here to click the button in Performance Assistant Window. Record & Playback tool does not catch it.
If session.findById("wnd[2]/usr/txtHELP_INFO-MESSAGENR").Text = "081" Then
'Some code
End If
'close popups
session.findById("wnd[2]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
End If

I found out that it is possible to display the Help in a Modal window (=Popup) rather than in a separate window Performance Assistant. Then it is possible with findById() functions to get the message number Popup raises > F1 > F9 > findByID(...).Text
To set the Help in a Modal window, the user must first (manually or programmatically) check a setting:

Related

Automatic Scroll SAP GUI

I'm trying to scroll until the end of the page and I recorded a script and did some changes. I thought of something like that
For i = 1 To END_PAGE
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").setCurrentCell i, "AUFNR"
Next
Where "AUFNR" is the name of the column I'm analyzing. But how do I know the END_PAGE if the code stops working when it checks a line it doesn't exist?
Here is a screenshot of the table I'm analyzing in SAP GUI
For example I could verify if EACH element has a text but unfortunely I don't know how to do that. Any ideas?

MS Access Database form not updating after SQL requery

I have a report that runs from a query. The query does use a global variable but this is not the problem but needed for the explanation. The function for the variable is:
Function Var1() As String
Var1 = strVar1
End Function
The query where statement is:
WHERE (((IIf([MinOfDueDayMin]<0,0,Int([MinOfDueDayMin]/7)+1))<Var1()+1) AND ((tblEquipment.Retired)=False))
which uses the var1 function
The criteria is on a field that is actually a calculation and that is where I think the problem starts.
The report is run for a command on another form using the following code:
strVar1 = InputBox("Enter Number of Weeks for report")
If strVar1 = "" Then Exit Sub
DoCmd.OpenReport "rptEquipPmSchedule", acViewReport
Everything works just fine
On the report I have a double click event that opens a form. This form uses part of the same query. (not the same one but two levels higher) thiS allow the user to change things so i expect to use requery for the report.
If i double click and then not even change anything and then go back to the report I have #ERROR in the fields that have the calculations
i put a me.requery in the activate event of the report. this did not work.
So I tried a work around.
When I double click the report field, i close the report and send the strVar1 value to the form that is opened. then when I close the form I reasign the strVar1 just in case it is lost be an assignment by another user (currently I am the only one using this but did it just to be sure it had the correct value.) Then I open the report again but still get the errors. I did not expect this at all. thought starting the report from scratch would certainly work. I even closed the form just after assigning strVar1.
then in final effort. When I close the form I run the exact same code:
strVar1 = InputBox("Enter Number of Weeks for report")
If strVar1 = "" Then Exit Sub
DoCmd.OpenReport "rptEquipPmSchedule", acViewReport
Which will force the user to input the value for strVal1. Even though this is not what I want but tried this for troubleshooting and I still get #ERROR.
When I run the report for a form that does not have any of the same field, no issues. When I run the report or keep it open with a requery from the form that has the same data, the report will not give the correct results. Note that if I run the query itself, the data in the query is correct.
i also tried using a number instead of Val1() in the query and got the same results.
i also tried the refresh button in the ribbon and get Unknown Function Name and all the data in the report is lost.
Anyone got any ideas??
While your textual explanation is difficult to understand the entire scope, consider re-assessing your workflow. The entire objective is to allow users to run customized criteria for reporting. And your main issue is the strVal does not persist in memory so all references to it fails.
Consider the following points:
Have users set criteria on a dedicated unbound form with button click for report where that report instance is immutable for viewing/printing only and if needed to be changed must be re-run (i.e., button re-clicked).
Access has no need for VBA's InputBox() as strVal can be an unbound textbox on this unbound form whose value remains intact for all open windows.
Have function and all its references point to form field: Form!myFormName!strValuetextbox
Because reports on pretty much any software/web app system is not used as a GUI interface to run actions, users will know if they intend to change report criteria, close current report or go back to entry point and change strVal then re-click button to re-run report.
Keep data entry/input (primary use of forms) separate from data export/output (like reports). From developer and user standpoint this compartmentalization will save you headaches down the road.

MS Access will occasionally remove checkboxes from my Yes/No fields and replace them with 0 and -1

My new database is built using a variety of queries and tables. These tables and queries have two checkbox fields that are set for "Test" and "Approved". The way that these come into play is that I have buttons on one form called "ApprovalForm" that open up another form called "ViewForm". The goal was that "ViewForm would change its subform's source object every time one of these buttons is clicked. ApprovalForm closes itself first, then ViewForm opens, then Subform.SourceObject is updated to the query specified by whatever button was clicked.
Private Sub View_NonSize_APL_Click()
On Error GoTo View_NonSize_APL_Click_Err
DoCmd.Close acForm, ("ApprovalForm")
DoCmd.OpenForm ("ViewForm")
Forms!ViewForm!View_Subform.SourceObject = "Query.NonSize - APL View"
Forms!ViewForm!View_Subform.Form.Requery
Forms!ViewForm.Form.Requery
Forms.ViewForm.Caption = "NonSize - APL View"
View_NonSize_APL_Click_Exit:
Exit Sub
View_NonSize_APL_Click_Err:
MsgBox Error$
Resume View_NonSize_APL_Click_Exit
End Sub
With the process finished, the final result should be that the fields are populated by the query, which is looking at a table off on the side. The user has no access to the table itself, just that specific select query. However, in rare occasions, the checkboxes will not load correctly, instead displaying as 0s and -1s. What is peculiar about this is that when you click the button on "ViewForm" that leads back to "ApprovalForm" and click the same exact button AGAIN, the checkboxes load correctly.
My guess is that it has something to do with how "ViewForm" loads in, and due to it being a business project, the computer that it is working on is less than optimal. I tried to remedy the situation by using "Requery" and "Refresh" in the code to hopefully reload the process. I have also tried the cumbersome route of having the form close after being loaded and immediately reloading again. (Open the form, load its query, close the form, then open the form again.) That actually proved to ruin the entire process.
Is there anything I can do to counter this problem?

LibreOffice Dialog Not working as intended

I have been trying to do this myself, but I just dont know how to define the problem. I have been writing a Macro for LibreOffice and it includes several dialogs. When I Run the macro I want to execute a Function after the dialog is visiable. I could not find the solution to this so I made another dialog which only shows "Loading, Wait..." and I inserted at the beggining and end of that function, dialog.Execute() and dialog.endExecute(). I guess the program stops at .execute() and im stuck at "Loading, Wait..." sign if I press "X" in the corner the program continues normally.
Best solution would be if I could run a function after the dialog is visible. So is there sort of a trigger ?
You can load the dialog and make it visible, but this would not activate the functions (buttons etc.), as this is what execute does
' StarBasic
' Tools
With GlobalScope.BasicLibraries
If ( Not .isLibraryLoaded("Tools") ) Then
.LoadLibrary( "Tools" )
End If
End With
sampleDialog = LoadDialog( "Standard", "Dialog1")
sampleDialog.setVisible(TRUE)
Does this help you?

Code "delete my account" button

Im using vb 2013. I tried to code my delete button after adding SQL delete in my Database. I wrote code in the class (I called it userFunc) calling the SQL DeleteItYourself with the variable DeleteIt. I created button with the toolbox and double clicked it, now I'm lost. I have session in the Login button to make sure it presents the user nickname. I redirected it to the homepage when the "I want to delete my account" located. Iactually don't know what to do with the button. I want it to call the function DeleteIt, but before the function Delete I want it to ask the user with some pop up alert if he's sure. Any ideas how to code my button?
(I'm a high school student and it's my project, they don't ACTUALLY teach us Java, unfortunately... They tell us to copy paste and try to understand)
Use this as a starting point:
If MsgBox("Are you sure you want to delete your account? This cannot be undone.", _
(MsgBoxStyle.Critical + MsgBoxStyle.OkCancel), _
"Confirm Account Deletion") = MsgBoxResult.Ok Then
UserFunc(DeleteIt)
End If
MsgBox displays a message box to the user, waits for a response, and returns the value of the button pressed. In the code above, the three arguments are:
The message to display
The style of the message box. Note how these are numeric values and can be added.
The title of the window.