Modules & VBA :: Validate Input In Text Box
Aug 5, 2014
I have a textbox where I need an afterupdate event, which should check that input is 3 letters followed by 3 numbers. The total is 6 characters, but always 3 letters + 3 numbers. If condition not met, a msgbox will be shown, for the user to input correctly, before being able to continue.
View Replies
ADVERTISEMENT
Sep 24, 2013
To facilitate input of special graphic characters such as the degree C and plus-and-minus symbols, I would like to use Alt-1 to Alt-9 key combinations, capture these keys in a KeyDown event procedure and change the keystroke to the desired graphical character code. I am using Access 2010 on Win7.
I first attempted to change the Shift integer to zero to reset the Alt-bit and set KeyCode to the desired character code, but this does not work. Hence I try to use the second common method of setting KeyCode to zero and use SendKeys to VBA-input the desired graphic character. However, strange things happens.
The test code is as follows:
Code:
Private Sub TestTB_KeyDown(KeyCode As Integer, Shift As Integer)
Dim i As Long
If (Shift And acAltMask) <> 0 And KeyCode <> 18 Then
' For i = 1 To 20000000 this For-loop is initially commented out
' Next i
[code]....
The above code as it is works OK and the '#' is successfully inputted to the TextBox field.However, if I comment out the MsgBox statement, the program waits for about 0.3 second and then instantly fills up the entire TextBox field by a large number of '#' characters.
If I move the MsgBox statement to after the SendKeys, no '#' character is inputted to the TextBox.If I comment out the MsgBox statement and activate the For loop at the looping count amount (but not much less), the program works fine.
View 5 Replies
View Related
Apr 13, 2014
I am trying to validate that the user selects at least one checkbox out of three on the form in Access 2010. They can select one, two or even all three if they wish, but at least one must be checked. I am using the following code attached to the click event of a command button. It was fine but seems to have stopped working. The control names are generic to illustrate my code. The form is unbound:
if (chk1 + chk2 + chk3) = 0 then
Msgbox "Please select at least one checkbox"
exit sub
end if
View 14 Replies
View Related
Jan 20, 2014
I would like to ask how can i validate the username and password in a textbox? I have a frmLogin and frmMain.
I have also a table called 'tblUsers' with column fields 'username and password'.
If username is not found in database then a msgbox will prompt 'Username is not yet created'.
If username is okay and password is incorrect then msgbox will prompt 'Incorrect password'
If username and password is okay, then a msgbox will prompt 'Successfully login' and will continue to frmMain.
View 3 Replies
View Related
Nov 27, 2014
I have a table called 'Klanten' which contains the rows 'password' and 'login' (and several rows not needed for this form)
So I'm trying to make a login form which first checks if something is entered (this part of the code seems to work).
Private Sub Knop13_Click()
'Check to see if data is entered into Username
If IsNull(Me.Username) Or Me.Username = "" Then
MsgBox "gelieve een login in te voeren.", vbOKOnly, "Required Data"
Me.Username.SetFocus
[Code] ....
But from then on i seem to have some issues.. The part of the code underneath seems to only work for the first 'login' and 'paswoord' in my table called "Klanten".
-Username is the name for the field where they enter their 'login'.
-Password is the name for the field where they enter their 'paswoord'
If Username.Value <> DLookup("[login]", "Klanten", "[Username]='" & Username & "'") Then
MsgBox "Invalid Username. Please try again.", vbOKOnly, "Invalid Entry!"
Exit Sub
End If
If Password.Value <> DLookup("[wachtwoord]", "Klanten", "[Password]='" & Password & "'") Then
MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Entry!"
Exit Sub
End If
Then as last part i would like to goto another form called 'Mainmenu' if both the Login and the Paswoord is correctly entered in the fields Username and Password. Here i have the most issues as this doesn't seem to do anything at the moment
If Password.Value = DLookup("[wachtwoord]", "Klanten", "[Username]='" & Username & "'") And Username.Value <> DLookup("[login]", "Klanten", "[Password]='" & Password & "'") Then DoCmd.OpenForm "Mainmenu"
End Sub
View 1 Replies
View Related
Feb 11, 2014
I am trying to write following code, I want Msg to pop, when all three condition are true, but it not working
'''Non Budgeted Projects need Explanation and Variance class"
If Me.ID.Value >= 90000 And and Me.Variance_Class = "" and Me.Comments_Explanation_Delta_____100K = "" Then
MsgBox "This project is Unbudgeted. Please Add 'Variance Class' and provide Explanation why this project is Unbudgeted project has been added.", vbExclamation, "Rules Checker..."
CheckRules = False
GoTo Exit_CheckRules
View 14 Replies
View Related
Jan 20, 2014
I'm new to access vba and I'm trying to create a login form. I have already my code to login but i want to validate the password in 'case sensitive' basis. Below is only what I've got so far.
Code:
Private Sub cmdLogin_Click() Dim login_validation As Variant login_validation = DLookup("Password", "tblLogin", "Username='" & Nz(txtUsername.Value, "") & "'") If Nz(login_validation, "") <> Nz([txtPassword].Value, "") Then MsgBox "Incorrect Password. Please try again." txtUsername.Value = "" txtPassword.Value = "" txtUsername.SetFocus Else MsgBox "Hi " & txtUsername.Value & "," & vbNewLine & vbNewLine & "you have successfully login!" DoCmd.OpenForm "frmMain" End If End Sub
View 5 Replies
View Related
Dec 24, 2013
I am trying to pass a date field from a Form and check if this date already exists within a table if so run this macro.
This is what I have so far...
Private Sub Command38_Click()
If DCount("*", "TblDietPlan", "[MealDate] = <> txtCusDate Then
stDocName = "McrPrint_LabelsWklyCR"
DoCmd.RunMacro stDocName
[Code] ....
View 2 Replies
View Related
Apr 15, 2014
I am having an issue using DCount to validate against 3 fields within my database. I have a booking form which contains a Staff member, viewing slot, and Viewing Date which is used to book property viewings.
I want the form to check that the booking doesn't already exist when the process booking button is pressed.
I am using the following statement:
Code:
If DCount("*", "Viewing", "[Staff_ID]=" & Me.[Staff_ID] & " AND [Viewing_Period] = " & Me.Viewing_Period & "' AND Viewing_Date = '" & Me.Viewing_Date) & "'" > 0 Then
MsgBox "Cannot book, booking already exists", vbCritical
End If
I always get the error "Syntax Error (Missing Operator)".
View 3 Replies
View Related
Jul 29, 2013
Can I look up and verify data on a "second" form based on a selected record from first (still open) form.
I am trying to allow users to select a User Name from a combo box list and then open "Change Password" form when they select "Change Password" for that selected user name.
My problem is that I can't figure out how to associate and verify the data tied to the user name selected on the previous (Login) form ( I am trying to validate the old password tied to that selected record).
I have the first login form created, and it's working just fine. I also have the change password form created (and it's displaying the user name selected from the first form using:
Code:
Private Sub Form_Load()
With Forms![frmLogin]![cboUserName]
Me.txtPwdChgUserID = .Column(2, .ListIndex)
End With
EndSub
I also have the code written to validate and confirm old password, new password and validate new password (when the save button is clicked). I have yet to update the password with the new password (still trying to figure that out).
Attached zip file has screen shots of the two forms.
View 3 Replies
View Related
May 11, 2006
Hi
I have an text box with an input mask of
>???????? to convert the text entered to capitals
1. Are there any other ways to convert to capitals?
2. With the way i have done the input mask if you click anywhere in the text box the curser starts from there. I would prefer it if no matter where in the text box you clicked the curser starts from the beginning
How do i do this ?
Thanks
View 1 Replies
View Related
Sep 9, 2006
Hello, all.
I have created a project in Access 2003 to track a student's progess toward a college degree. I want the user to enter their student id in a text box on a form, look up if that user is present in the student table, and if not show the form to enter their student information.
I can't get the text box to accept user input, and return the student info as a single record on the form. I have a query but I don't know how to set the proprerties to run the query.
Thanks for any help.
View 1 Replies
View Related
Jun 29, 2006
I am trying to produce a query that will search for multiple records by job id entered into a text box eg 17656,18768,15679.
The example i have found uses the (LIKE '*value*') so if i type in part of a job id (176) it will display all records starting with 176. I would like to enter specific job id numbers seperated by a , and only display these
Would be grateful for any help
View 2 Replies
View Related
May 26, 2013
I want numeric only input for a certain textbox. I can use a ISNUMERIC function to test this, but prefer to use the Keypress event. So far got the following:
Code:
Private Sub txt_Position_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 8 ' backspace
Case Asc("1") To Asc("9")
Case Asc("-")
If InStr(1, Me.txt_Position.Text, "-") > 0 Or Me.txt_Position.SelStart > 0 Then
[code]...
It is working alright, except I want to avoid input that has multiple leading zeros, such as 00000 or -00000 (i.e. minus sign with mulitple leading zeros).
View 10 Replies
View Related
Oct 2, 2014
Is it possible in Access to use an input value (text) as a field name? I want to access a field based on what the user enters.
View 6 Replies
View Related
Sep 19, 2011
I have a table with a field named 'Comments'. On the form, I would like to have a text input and a command button. After the user enter the comments onto the textbox and subsequently click on the command button, the comments will be input onto the 'Comments' field of the table.
Q1. How can the text box be link to the 'Comments' field of the table?
Q2. Only after I press the command button then the input text on the text box will be transfer to the table. What is the command for that?
View 3 Replies
View Related
Mar 6, 2008
Good day... beginner Access user (converting from Lotus Approach) and need some help please. Please excuse my novice... I'm on a deadline at work and need help:
-- Data source: MS Excel Table
-- Database form: MS Access 2003
My form is using the excel table as its data source. There are two fields: TELEPHONE AND FAX
When I try to use the input mask in Access to view the numbers in TELEPHONE FORMAT, it keeps telling me the input mask works only on text or date fields. Do I have to first modify the field format in excel? What does this error mean?
View 2 Replies
View Related
Jul 9, 2013
I'm trying to apply a custom input mask to a text box control. The text box must contain a 43 character string, broken into sections as follows :
AAAA-AAAAA-AAAAA-AAAAAA-AAAAAAAAA-AAAAAAAAAAA-AAA
(The format is quite strict and always comprises alphanumeric characters , hence I figured an input mask would, if nothing else, support the user to key the string accurately from its constituent parts...)
However, when I try to apply the input mask to the text box, I seem to run out of characters - I get as far as the below but the input mask wizard won't let me extend the mask to the final 8 characters
AAAA-AAAAA-AAAAA-AAAAAA-AAAAAAAAA-AAAAAAAAAAA-AAA
Are input masks restricted to 35 characters in length? And if so, how else could I make this, admittedly complex, text input more manageable for end users?
View 2 Replies
View Related
Sep 20, 2011
I have 2 text boxes and 1 push button for each text box for input to table. When I click on 'SaveInput1' only Input1 is save onto the Table and when 'SaveInput2' is click only Input2 is save. I want each command button to save each input separately.
I know ACCESS have a SAVE RECORD function, but I do not want to use this because it will save the entire record all at once.
TextBox1 = Input1
TextBox2 = Input2
Commandbutton1 = SaveInput1
Commandbutton2 = SaveInput2
View 1 Replies
View Related
Jan 5, 2005
This is the first time that I have done any major work with forms. After I thought I had finished a problem came up. There are several forms that are use to input information into a table. When the form is opened it grabs an automated number for tracking. The problem is, that if the form is opened and then closed it creates a line of data with all null values.
What I would like to do is have the form open, the user fills out the information, and upon pressing the "save" button, the data will save to the table. I think I need to have each text box write to a variable and then save on the click event. Or I could be completely wrong and need to do something else.
i'm guessing this is something I would learn in Forms 101 if i had ever taken that type of course
Thanks
View 7 Replies
View Related
Jan 10, 2014
I want to be able to have two text boxes on my form that firstly concatenate the values inputted and then saves this string to a field.
It's a "new record" form that generates a new record in table "tblUsers".
txtB1 & txtB2 and the text boxes would represent First Name and Last Name.
But it can't be allowed to be saved as the acctual names. - Insead I'm looking for a way to take the first two or three letters of the name and concatenate these into one string of text and save that string to the field tblUsers.ConcatenatedName.
I.E.txtB1:"Carl"
txtB2:"Chapelle"
would generate "CarCha" and save that from the form to the field ConcatenatedName in tblUsers.
Btw, the values form txtB1 and txtB2 (Carl & Chapelle) cant be saved anywhere either!
Found the answer myself;
create a txtB3
And set that source to Left([txtB1];3) & " " & Left([txtB2];3)
View 1 Replies
View Related
Jan 9, 2014
Is there a way to setup the format on fields to only allow text inputs, no numbers wanted. I know I can do this at the table level but is some cases numbers are ok. So I want to code it so I can control when numbers are ok and when there not.
View 1 Replies
View Related
Nov 18, 2013
I have a report that selects and shows records where a specified date field is within the range of 2 dates that the user enters.I created 2 unbound textboxes on the report with a Shortdate format and InputMask 0000-00-00;0;_.When user enter correct dates, then everything works fine: selection is properly done, the right records show up.But I have 2 problems:
1-the input mask is not working: the user can input anything!
2-the 2 unbound textboxes do not show the dates entered by the user.
It seems the value entered bu user does not go straight into the unbound textbox. How do I either intercept the value entered by the user directly into the unbound textbox or via a variable?
View 1 Replies
View Related
Nov 8, 2014
I'm trying to set an input mask for a text field.
The data will be 1 to 4 digits preceded by 1/
I have tried the masks 1/####;; , "1"/####;; 1/####;; , "1"/#### , '1'/#### but none work as if the first nubber entered is a 1 it replaces the 1 in 1/
If it is a 2 then it works fine.
I can set the 1 to and f (f/) and it works no problem.
View 2 Replies
View Related
Feb 24, 2014
I just started my project database on my subject ITM4. My Database is entitled PCExpress Inventory System. I would like to know how to input (Text) in a Field where the Data Type is (Number) just like the North Wind.
View 3 Replies
View Related
Feb 10, 2014
Can you update a text box on a form based on input of a date control? Here is what I have. I have several date controls on my form, and I want to update a status textbox based on which of these date boxes is filled out, but I need the status to be filled into the table as well. Do I update the field on the table, and then requery the text box? Is there some other method for accomplishing this?
View 9 Replies
View Related