If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Message if textbox is empty
I have a search textbox and a button next to it which initiates the search
using the value the textbox contains. I want a message to pop up if the textbox doesn't contain any value. I presume this uses the validiation thingy but I have no idea how to use that. Any ideas? |
#2
|
|||
|
|||
If Len(Trim$(Me!NameOfTextBox & vbNullString)) = 0 Then
This will catch Null values, empty strings, and entries that contain nothing but one or more spaces. -- Brendan Reynolds (MVP) http://brenreyn.blogspot.com The spammers and script-kiddies have succeeded in making it impossible for me to use a real e-mail address in public newsgroups. E-mail replies to this post will be deleted without being read. Any e-mail claiming to be from brenreyn at indigo dot ie that is not digitally signed by me with a GlobalSign digital certificate is a forgery and should be deleted without being read. Follow-up questions should in general be posted to the newsgroup, but if you have a good reason to send me e-mail, you'll find a useable e-mail address at the URL above. "Andrew Wilkins" wrote in message ... I have a search textbox and a button next to it which initiates the search using the value the textbox contains. I want a message to pop up if the textbox doesn't contain any value. I presume this uses the validiation thingy but I have no idea how to use that. Any ideas? |
#3
|
|||
|
|||
Add this to the click event of your button.
If Me.YourTextBox Is Null Then MsgBox "Please Enter some value" Me.YourTextBox.SetFocus Else 'Run Your Search Code Here End If -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... I have a search textbox and a button next to it which initiates the search using the value the textbox contains. I want a message to pop up if the textbox doesn't contain any value. I presume this uses the validiation thingy but I have no idea how to use that. Any ideas? |
#4
|
|||
|
|||
Where do I put that code? Sorry, but I really am an Access novice!
"Lynn Trapp" wrote: Add this to the click event of your button. If Me.YourTextBox Is Null Then MsgBox "Please Enter some value" Me.YourTextBox.SetFocus Else 'Run Your Search Code Here End If -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... I have a search textbox and a button next to it which initiates the search using the value the textbox contains. I want a message to pop up if the textbox doesn't contain any value. I presume this uses the validiation thingy but I have no idea how to use that. Any ideas? |
#5
|
|||
|
|||
You said you have a button that runs a search. That button has some code
behind it. If you click on the button while the form is in design view and make sure the property sheet is open, you can see that there is probably an Event Procedure in the On Click event of the button. Select that and click the button to the right of the event procedure. This will open the code for you and you add it there. -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... Where do I put that code? Sorry, but I really am an Access novice! "Lynn Trapp" wrote: Add this to the click event of your button. If Me.YourTextBox Is Null Then MsgBox "Please Enter some value" Me.YourTextBox.SetFocus Else 'Run Your Search Code Here End If -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... I have a search textbox and a button next to it which initiates the search using the value the textbox contains. I want a message to pop up if the textbox doesn't contain any value. I presume this uses the validiation thingy but I have no idea how to use that. Any ideas? |
#6
|
|||
|
|||
The following is the On Click procedure code for my search button (called
'Command200'). 'Text187' is the textbox that contains the search value that should match the field 'ComplaintNumber'. Where do I put the IF statement you gave me? I tried putting it in and Access says there is an object missing. --- Private Sub Command200_Click() On Error GoTo Err_Command200_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "Form-Browse-Complaints" stLinkCriteria = "[ComplaintNumber]=" & Me![Text187] DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command200_Click: Exit Sub Err_Command200_Click: MsgBox Err.Description Resume Exit_Command200_Click End Sub --- Thanks. "Lynn Trapp" wrote: You said you have a button that runs a search. That button has some code behind it. If you click on the button while the form is in design view and make sure the property sheet is open, you can see that there is probably an Event Procedure in the On Click event of the button. Select that and click the button to the right of the event procedure. This will open the code for you and you add it there. -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... Where do I put that code? Sorry, but I really am an Access novice! "Lynn Trapp" wrote: Add this to the click event of your button. If Me.YourTextBox Is Null Then MsgBox "Please Enter some value" Me.YourTextBox.SetFocus Else 'Run Your Search Code Here End If -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... I have a search textbox and a button next to it which initiates the search using the value the textbox contains. I want a message to pop up if the textbox doesn't contain any value. I presume this uses the validiation thingy but I have no idea how to use that. Any ideas? |
#7
|
|||
|
|||
stDocName = "Form-Browse-Complaints"
IF Me![Text187] Is Null Then MsgBox "Put Something In The field" Me![Text187].SetFocus Else stLinkCriteria = "[ComplaintNumber]=" & Me![Text187] DoCmd.OpenForm stDocName, , , stLinkCriteria End If -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... The following is the On Click procedure code for my search button (called 'Command200'). 'Text187' is the textbox that contains the search value that should match the field 'ComplaintNumber'. Where do I put the IF statement you gave me? I tried putting it in and Access says there is an object missing. --- Private Sub Command200_Click() On Error GoTo Err_Command200_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "Form-Browse-Complaints" stLinkCriteria = "[ComplaintNumber]=" & Me![Text187] DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command200_Click: Exit Sub Err_Command200_Click: MsgBox Err.Description Resume Exit_Command200_Click End Sub --- Thanks. "Lynn Trapp" wrote: You said you have a button that runs a search. That button has some code behind it. If you click on the button while the form is in design view and make sure the property sheet is open, you can see that there is probably an Event Procedure in the On Click event of the button. Select that and click the button to the right of the event procedure. This will open the code for you and you add it there. -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... Where do I put that code? Sorry, but I really am an Access novice! "Lynn Trapp" wrote: Add this to the click event of your button. If Me.YourTextBox Is Null Then MsgBox "Please Enter some value" Me.YourTextBox.SetFocus Else 'Run Your Search Code Here End If -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... I have a search textbox and a button next to it which initiates the search using the value the textbox contains. I want a message to pop up if the textbox doesn't contain any value. I presume this uses the validiation thingy but I have no idea how to use that. Any ideas? |
#8
|
|||
|
|||
Andrew, this is where you put the code:
Private Sub Command200_Click() On Error GoTo Err_Command200_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "Form-Browse-Complaints" If Len(Trim$(Me!NameOfTextBox & vbNullString)) = 0 Then MsgBox "Please Enter some value" Me.Text187.SetFocus Else stLinkCriteria = "[ComplaintNumber]=" & Me![Text187] DoCmd.OpenForm stDocName, , , stLinkCriteria End If Exit_Command200_Click: Exit Sub Err_Command200_Click: MsgBox Err.Description Resume Exit_Command200_Click End Sub Hope this helps! Reggie Andrew Wilkins wrote: The following is the On Click procedure code for my search button (called 'Command200'). 'Text187' is the textbox that contains the search value that should match the field 'ComplaintNumber'. Where do I put the IF statement you gave me? I tried putting it in and Access says there is an object missing. --- Private Sub Command200_Click() On Error GoTo Err_Command200_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "Form-Browse-Complaints" stLinkCriteria = "[ComplaintNumber]=" & Me![Text187] DoCmd.OpenForm stDocName, , , stLinkCriteria Exit_Command200_Click: Exit Sub Err_Command200_Click: MsgBox Err.Description Resume Exit_Command200_Click End Sub --- Thanks. "Lynn Trapp" wrote: You said you have a button that runs a search. That button has some code behind it. If you click on the button while the form is in design view and make sure the property sheet is open, you can see that there is probably an Event Procedure in the On Click event of the button. Select that and click the button to the right of the event procedure. This will open the code for you and you add it there. -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... Where do I put that code? Sorry, but I really am an Access novice! "Lynn Trapp" wrote: Add this to the click event of your button. If Me.YourTextBox Is Null Then MsgBox "Please Enter some value" Me.YourTextBox.SetFocus Else 'Run Your Search Code Here End If -- Lynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm "Andrew Wilkins" wrote in message ... I have a search textbox and a button next to it which initiates the search using the value the textbox contains. I want a message to pop up if the textbox doesn't contain any value. I presume this uses the validiation thingy but I have no idea how to use that. Any ideas? |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem Updating New Messages from NTTP News Server OE | Chad Harris | Outlook Express | 19 | February 7th, 2005 07:21 PM |
lost email folders | Gregg Strand | Outlook Express | 22 | August 12th, 2004 12:59 PM |
Inbox Emptied - 4th time | JPoldo | Outlook Express | 6 | July 24th, 2004 01:31 PM |
msimn.exe-Application error message | Blondenblue_uk | Outlook Express | 2 | July 23rd, 2004 01:03 PM |
return to inbox after deleting a message | Dan Spencer | Outlook Express | 4 | June 6th, 2004 08:25 AM |