Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I am trying to write an If statement in VBA that is somewhat in this format:
If Button A is clicked
Then
Open a file
End If
I am stuck at the first part where I am not sure how to write the portion for the "If Button A is clicked". Would greatly appreciate any advice on this.
Code
The expected result would be that the file opens when the user presses button A and specifies the location of the file that is to be opened.
A button being clicked is an ephemeral event that happens, not state that you can test with an "if". Set an event handler to call the code when the button is clicked, and don't worry about an "if".
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Say i press button1 and this starts an infinite while loop. How do i make it so that if button2 is pressed, it will pause the current action and do the code inside button2 firs before carrying on with the process in button1?
If the first button really is in an infinite loop, you can't. You might be able to make a button that would interrupt other code, but the event handler for that button can't ever fire because the first button is preventing your app from processing event messages.
So be careful not to create infinite (or even long-running) event handlers (of any type) on the default/UI thread.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am using VBA code to get data from user by using InputBox function. I want a user to write in Arabic.
But, when I run it, I found strange characters although I can write in Arabic normally in Excel sheets.
Can anyone help?
Make a custom form, that works as InputBox.
There you would be able to write in any other language than English.
Otherwise you would be getting the ?????????????????????
Simply add a label element for the input and button elements for Ok and Cancel.
In general, this is much better than InputBox, because you can control the TextAlign property, which is different in Arabic than in English.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
net Programmers
I am in a trouble
I want to display messagebox after a while of time
i did this but the problem is that the messagebox appears behind the other windows of the active programs
I want a code that displays the messagebox over all opened windows to make the user see it
and THANKS
You can't set TopMost on a message box. However, you could create your own class/dialog set TopMost to true on it and then use ShowDialog to display it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I have my form set up to be able to drop files into a textbox, and also drag the files out of the textbox, thus clearing the textbox. The kicker is that the drag out of the textbox has to be dropped on the form. If I try to drag it outside the form, then it crashes. I would like for the drag and drop to ignore when the mouse is moved outside of the form. Any ideas? Here's the error I get when I drag the file out of the textbox and out of the form:
Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC))
You can keep the cursor inside of the form. Cursor.Clip
MouseDown event:
Cursor.Clip = Me.RectangleToScreen(Me.ClientRectangle)
MouseUp Event:
Cursor.Clip = Nothing
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have an access form in which after the user performs few operations a message box will appear. When the user clicks "OK" on the message box I want to close the current form and open a new form. How can I do this?
the VBA code execution is suspended until the user clicks ok. Therefore the next line of code after the msgbox call will be your spot to do the 'magic'
You want to open the new form first, then close the current form.
You can either do it by just putting the code directly after the MsgBox command, or by checking the response of the user in a multi-response messagebox. For example:
If MsgBox("Do you really want to continue?" & vbCrLf, vbYesNo) = vbYes Then
DoCmd.Close MyFormName
Else
...Perform some other function
End If
This will pop up a messagebox with both Yes and No buttons, and allows you to run some alternate code if the response is No.