So, I literally have one more thing to do to finish my Calculator, which is make an error box popup if the textbox is empty. Currently, it shows a message, saying an error has occurred. I want it to simply launch a popup if the textbox is empty, and a "Continue" button to close the window.
If you want a simple popup, try this:
if textboxNum1.Text = "" OR textboxNum2.Text = "" Then
MsgBox("Textboxes are empty!")
else
'Enter process here
End if
Or try this:
if(textboxNum1.Text = "" OR textboxNum2.Text = "") Then
MsgBox("Textboxes are empty!")
else
'Enter process here
End if
Related
I have a RichTextBox (RTB) that I am using to save text to a SQLite DB
To prevent the user from not entering text in the RTB I have implemented the code below
The issue is after the user enters some text in the RTB clicking the SAVE button will not bypass the test
Question is there a better way to do this and why is this code failing?
If Len(Trim(rtbEnter.Text = " ")) Then
tbMessage.ForeColor = Color.Red
tbMessage.Text = "No Data to Enter"
Return
End If
In access I am trying to not let the user exit a textbox unless they have filled it out (i.e. not left it null). This is to be done in a function in order to cut down on code. In VBA is there some way to stop the user from exiting the function? (I know about setting the focus but I need the code to work from a multitude of different textboxes)
For reference my current code is as follows;
Function Reload()
If IsNull(EmployeeID.Value) Or IsNull([First Name].Value) Or IsNull([Surname].Value) Or IsNull(DOB.Value) Or IsNull(Position.Value) Or IsNull(Position.Value) Or IsNull(Mobile.Value) Or IsNull(Email.Value) Or IsNull(Address.Value) Or IsNull(Suburb.Value) Or IsNull(Postcode.Value) Or IsNull([Start Date].Value) Or IsNull(UserLogin.Value) Or IsNull(UserPassword.Value) Then
MsgBox "Please fill out all fields"
Else
DoCmd.RunCommand acCmdSaveRecord
Form.Refresh
End If
End Function
Thanks
The best technique I know is to use the BeforeUpdate event to run data validation. Using your if statements if the data is not valid then set
Cancel = True
and the data will not write. You would probably prefer to disable the default record navigation and form close buttons and use custom buttons so that you can trap the invalid data error and prevent moving to a new record or closing the form. But even if you allow the user to use the built in navigation buttons or close button Access will throw up error messages about being unable to save the current record and prompt the user if he wants to proceed.
You can also go a step further and captue which fields are invalid and present a message box.
Msgbox ("The following fields were left blank and must be entered to save this record:" & vbCrLf & "Field 1" & vbCrLf & "Field 2")
A little modification of the text input limiter i use in our chat room should help. New function I have called it MustINPUT and call it on the LostFocus of the text boxes that you don't want to move from with out input.
Private Sub MyTextBox_LostFocus()
Call MustINPUT (Me.MyTextBox, 0)
End Sub
Just change the message for your users.
Sub MustINPUT(ctl As Control, iMaxLen As Integer)
'Call MustINPUT(Me.txtSayThis, 0)
If Len(ctl.Text) = iMaxLen Then
MsgBox "Please Type something", vbExclamation, "Input Needed"
ctl.Text = Left(ctl.Text, iMaxLen)
ctl.SelStart = iMaxLen
End If
End Sub
Hope this help. DR ,
I have a series of text boxes that are hidden, except one which users enter a value into. After a button is pressed, this text box disappears and the rest appear. From there, I want users to be able to enter different values into each text box. These values will be saved as variables. From there, users press a button and enter new values into the text boxes, until values have been entered into the text boxes for each number up to the first value entered into the hidden text box.
I'm not sure how else to explain this, but please let me know if you have any questions.
Correct me if im wrong. i think you want an input in different textbox?
Like textbox1 = 1, textbox2 = 2 and so on. If this is right then try this.
Lets try this to your 3 textbox for an example.
Private Sub Button_Click(sender As Object, e As EventArgs) Handles Button.Click
If TextBox1.Visible = True Then
If Trim(TextBox1.Text) <> "" Then
TextBox1.Visible = False
TextBox2.visible = True
Else
MsgBox("Required")
'or user error provider.
End If
Exit Sub
End If
If textbox2.visible = True Then
If Trim(TextBox2.Text) <> "" Then
TextBox2.Visible = False
TextBox3.visible = True
Else
MsgBox("Required")
'or user error provider.
End If
Exit Sub
End If
'and so on
End Sub
hope this is what you want. just basic but maybe usefull :)
This is the workflow of what you want to accomplish in JavaScript. VB.Net has similar functions to Visibility. https://msdn.microsoft.com/en-us/library/ms748821(v=vs.85).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-2
In the visual editor you can create buttons and add Click events to them, this is basic so I won't tell you how to do it. Google if you can't.
var options = document.getElementsByClassName("options");
var optionsSetOne = document.getByClassName('optionsSetOne');
This will select all your options. Now that you have all your options selected and in a variable called options you can play around with the visibility, as the user progresses thought the buttons.
First I would set all my options to hidden with:
options.style.visibility = 'hidden';
After the users progresses and clicks the button, I will make the first set of the options visible. With:
$('#buttonOne').click(function(){
optionsSetOne.style.visibility = 'visible';
});
This is the basic workflow of what you want to accomplish, you have to figure out how to save all the information the user gives to you.
I am opening a webpage using VBA code which contains form where data will be filled by user. I have excel file which contains data. I write VBA code that read the data from excel and put it on webpage. After filling information on webpage I click on Save button. All this work I had done using VBA code so that it can be done automatically. I have 500 users data hence I run the loop 500 times. All it done fines.
Only one problem come and it is that after filling data in webpage form when I click on save button a popup message comes "Your data saved successfully". It has "OK" button. Now my program stops here and need user intervention to manually click on "OK" button.
Is there any way using VBA code by which we can stop this popup message box, so that manual intervention is no longer required?
I read the webpage and Javascript written for webpage also. I found that when Save button is clicked a function called savedetails() . Inside this function a alert() function is there. Sample code here
function saveDetails()
{
/* get details of member*/
---
---
---
---
---
if (xml.status == 200 || window.location.href.indexOf("http") == -1) {
var successCode = "";
alert("Data Saved Successfully");
var tes = xml.responseText;
/* if (successCode == '1') { */
document.webDataForm.submit();
remove_popup();
};
}
VBA Code For Each htmlInput In htmlColl
If Trim(htmlInput.ID) = "btn" Then
If Trim(htmlInput.Name) = "btnfinal" Then
htmlInput.Click 'After this "Data Saved Successfully popup message comes and program need user intervention
temp = htmlInput.getAttribute("onClick")
MsgBox temp
'IE.document.getElementById("clearRelItems").removeAttribute ("o n C l i c k")
'Call iedoc.parentWindow.execScript("window.confirm = function saveBankDetails() {return true}", "JavaScript") // Not worked
'htmlInput.removeAttribute ("onClick") //Not worked
'htmlInput.setAttribute "onClick", "return TRUE" //Not worked
'Application.SendKeys "{ENTER}", True // Not worked
Exit For
End If
End If
Next htmlInput
You could try wrapping the line with the Application.DisplayAlerts function that produces the display box you don't want;
eg.
If Trim(htmlInput.ID) = "btn" Then
If Trim(htmlInput.Name) = "btnfinal" Then
Application.DisplayAlerts = False
htmlInput.Click
Application.DisplayAlerts = True
.... Further Code
I had this problem and the only way I could solve it was by writing a vb script that identifies the pop up and closes it...
After that, you just need to call it from your vba code.
Using telerik and the radmenu, do you know how to check if the item exists by text
my menu contains the text "menu1"
If I use menu.FindItemByText("menu1").Enabled = False this will disable the button
BUT
If I use menu.FindItemByText("menuTEST").Enabled = False then I get an exception as this button does not exist.
How do I stop the error?
I tried this below but it say it cant return booloen
If menu.FindItemByText("menuTEST") then
'do this
End If
Try this:
If Not(menu.FindItemByText("menuTEST") Is Nothing) then
'do this
End If