473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Display an error message if combo box is blank.

36
i have used a combo box on a form linked to a query. the user is to select a value from the combo box and this click 'Find'. But on an old occasion where the user has forgotten to select a value from the combo box, left blank, i want it to display an error message saying, "Select value", when clicked 'Find'.

As well as displaying an error message, can you also instead of displaying an error message have it to automatically open a form which has the error message and also, the instructions for the user.

It would be great if someone could explain how i could achieve both, the error message and to automatically open a form. any help would be highly appreciated.
Apr 10 '07 #1
4 8204
MMcCarthy
14,534 Expert Mod 8TB
What code are you using on your find button.

Mary
Apr 10 '07 #2
atiq
36
What code are you using on your find button.

Mary
The code for the find button is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch_Click()
  2.     If IsNull(Combo0) Then
  3.        MsgBox "You must choose behaviour type." _
  4.        & vbCrLf & "Please try again.", vbExclamation, _
  5.        "More information required."
  6.  
  7.  
  8.        Exit Sub
  9.     End If
  10.     DoCmd.OpenReport "rptSearchByStudent", acViewPreview
  11.     DoCmd.Close acForm, "frmSearchByStudent"
  12. End Sub
Apr 10 '07 #3
pks00
280 Expert 100+
slight change to your code, should hopefully do it
dont use exit sub, instead use the Else

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch_Click()
  2.  
  3.     If IsNull(Combo0) Then
  4.        Docmd.OpenForm "myerrorform", , , , , acDialog
  5.     Else
  6.         DoCmd.OpenReport "rptSearchByStudent", acViewPreview
  7.         DoCmd.Close acForm, "frmSearchByStudent"
  8.     End If
  9. End Sub
where myerrorform is your form with the error message and instructions
Apr 10 '07 #4
atiq
36
Sorted! it's working now. Thank you very much for you help. hope you have a great day.
Apr 10 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Albert Spencil | last post by:
This error shows when I check Netscape's "javascript:" . Doesn't seem to present a problem as the site works OK. Still I would like to get rid of it. "Security Error: Content at...
2
by: William Payne | last post by:
Hello. Consider the following code snippet (pseudo-code). void foo() { /* do stuff */ if fatal error occurs { throw "error message"; }
0
by: Lauren Wilson | last post by:
Hi Folks, I have a combo box on a multi-record form. About every other time I select something from the STATIC list of options, I get this result: What on earth is the cause of this error...
0
by: VRWC | last post by:
Hi Folks, I have a combo box on a multi-record form. About every other time I select something from the STATIC list of options, I get this result: What on earth is the cause of this error...
2
by: Chuck | last post by:
I'm using A97. Table1 and table2 are related with a one to many relationship of a text field. Table2 has the primary key which is indexed with no duplicates. A data entry form for table1 gets...
14
by: Tom | last post by:
Using AccessXP in 2000 mode. I have the following tables --- TblLocation LocationID PropertyID StateID CountyID CityID
2
by: c676228 | last post by:
Hi, I have several user controls like email, phone,ssn etc. each has it's own validation message in its user control already. When I bring all those user controls in an aspx page, I would like to...
8
by: durga2005 | last post by:
Hi I have used webgrid control using template columns to display data from the database. When I click edit button and enter the data, I m validating the data using regular expression...
5
by: Miro | last post by:
I have a re-occuring problem in vs2008 and I have wondered if someone else has run into this. As I flip between 'ViewCode' and 'Design' mode of a form, suddenly what will happen is that the form...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.