473,396 Members | 1,893 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,396 software developers and data experts.

Why “Run time error ‘247.You entered an expression that has no value. with check box

Jerry Maiapu
259 100+
Can someone help me with this funny problem?
I just created a custom criteria form that a user enters data to open a report.
.
I have two unbound check boxes namely 1. chkshowcredits and 2. chknocredits that a user must select/tick one of them before opening the report.

The on click event (code) of the OK button on the form to preview the report is below:


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command6_Click()
  2. If IsNull(Me.Oyear) = True Or IsNull(Me.ndate) = True Then
  3. MsgBox "One of the required dates is missing", vbCritical + vbOKOnly, "Date Error"
  4. End If
  5. If Me.Oyear <= Me.ndate Then
  6. MsgBox "Oldest date must be less than Newst date", vbCritical + vbOKOnly, "Date Error"
  7. Exit Sub
  8. End If
  9.  
  10. If me.chkshowcredits.Value = True Then'error occurs here
  11. DoCmd.OpenReport "Summary with Credits", acViewPreview
  12. ElseIf me.chknocredits.Value = True Then'error occurs here
  13. DoCmd.OpenReport "Summary With No Credits", acViewPreview
  14. Else
  15. MsgBox "Select an option to show or not to show credits in the report", vbCritical + vbOKOnly, "Data Missing"
  16. End If
  17. End Sub
  18.  
  19.  
  20.  
Rest of the validation in the code above is fine but the error message occurs exactly at code line#10 and could possibly occur again at line#12, i.e when I debug it. An this is to do with the two unbound check boxes.

What is the problem.? I just want the user to tick one of the check boxes to open a particular report based on the check box ticked.
I am I wrong somewhere.?

Can one smart person help me out here. I tried to solve this but its hurting my brain.

Thanks..
Jun 7 '10 #1

✓ answered by ADezii

@ahmedtharwat19
Assuming:
  1. There are no Syntax Errors on the Control Names.
  2. OYear and nDate are Valid Dates.
  3. The Check Boxes are mutually exclusive.
  4. The report Names are correct.
  5. If the above assumptions are all correct, the code listed will work fine.
    Expand|Select|Wrap|Line Numbers
    1. If IsNull(Me.OYear) Or IsNull(Me.nDate) Then
    2.   MsgBox "One of the required dates is missing", vbCritical + vbOKOnly, "Date Error"
    3.     Exit Sub
    4. End If
    5.  
    6. If Not IsDate(Me.OYear) Or Not IsDate(Me.nDate) Then
    7.   MsgBox "At least one Invalid Date", vbCritical + vbOKOnly, "Invalid Date Error"
    8.     Exit Sub
    9. End If
    10.  
    11. If CDate(Me.OYear) <= CDate(Me.nDate) Then
    12.   MsgBox "Oldest date must be less than Newest date", vbCritical + vbOKOnly, "Date Error"
    13.     Exit Sub
    14. End If
    15.  
    16. If Me.chkShowCredits Then
    17.   DoCmd.OpenReport "Summary with Credits", acViewPreview
    18. ElseIf Me.chkNoCredits Then
    19.   DoCmd.OpenReport "Summary With No Credits", acViewPreview
    20. Else
    21.   MsgBox "Select an option to show or not to show credits in the report", _
    22.           vbCritical + vbOKOnly, "Data Missing"
    23. End If

11 7160
HI Jerry Maiapu


Expand|Select|Wrap|Line Numbers
  1. If Me.chkshowcredits.Value = True Then'error occurs here 
  2. DoCmd.OpenReport "Summary with Credits", acViewPreview 
  3. ElseIf Me.chknocredits.Value = True Then'error occurs here 
I THINK THE ERROR IN THIS CODE REASON TO
THE VALUE IS NOT EQUAL TRUE OR FALSE JUST EQUAL A NUMBER

TRUE=1,FALSE=0 IN CHECKBOX

TRY THIS CODE AND TELL ME

Expand|Select|Wrap|Line Numbers
  1. If Me.chkshowcredits.Value = 1 Then 'EDIT BY MEDO
  2. DoCmd.OpenReport "Summary with Credits", acViewPreview 
  3. ElseIf Me.chknocredits.Value = 1 Then'EDIT BY MEDO
BEST REGARDS ,

AHMED THARWAT(MEDO)
Jun 9 '10 #2
Jerry Maiapu
259 100+
@ahmedtharwat19
AHMED THARWAT(MEDO),
Thank you in trying to help but I tried that too and still the error message is persisting to pop up.

After many attempts I have just done away with the check box business and am using a combo box for the users to select from the two text values, YES & NO which is fine.

However if you still have some solution/suggestions do post it.

Thank you.

Jerry
Jun 10 '10 #3
@Jerry Maiapu
Jerry,

I Need To Help.

Can You Attach The sample Problem To solve It.
Jun 10 '10 #4
Jerry Maiapu
259 100+
Thank you in showing interest to help. It is really kind of you.
Ok, first of all I cannot attach the the mdb file coz it is about 17mb but can I give you the form property details and maybe a screen shot of the form?
Jun 11 '10 #5
MMcCarthy
14,534 Expert Mod 8TB
Instead of adding two individual checkboxes add an option group with two possible values. Now the values will default to 1 and 2. You then use a SELECT CASE function to decide what the selection triggers. Something like the following:

Expand|Select|Wrap|Line Numbers
  1. 'lets assume you name the option group object as rptFrame
  2. 'In the after update event of that object.
  3. Private Sub rptFrame_AfterUpdate()
  4.  
  5.     SELECT CASE rptFrame
  6.  
  7.     Case 1
  8.         Docmd.OpenReport "Report1"
  9.  
  10.     Case 2
  11.         Docmd.OpenReport "Report2"
  12.  
  13.     END SELECT
  14.  
  15. End Sub
Jun 11 '10 #6
Jerry Maiapu,

Do It In Option Group, I Think It The Best Of You,
Because The First If The Value of CheckBox1 Is True And You You Check The Secound CheckBox Value To Be True,The First Still True, But In Option Group This Problem Will Done.
I Attach The Sample For That.

Best Regards,

Ahmed Tharwat (Medo)
Attached Files
File Type: zip Option Group By Medo.zip (13.8 KB, 124 views)
Jun 12 '10 #7
ADezii
8,834 Expert 8TB
@ahmedtharwat19
Assuming:
  1. There are no Syntax Errors on the Control Names.
  2. OYear and nDate are Valid Dates.
  3. The Check Boxes are mutually exclusive.
  4. The report Names are correct.
  5. If the above assumptions are all correct, the code listed will work fine.
    Expand|Select|Wrap|Line Numbers
    1. If IsNull(Me.OYear) Or IsNull(Me.nDate) Then
    2.   MsgBox "One of the required dates is missing", vbCritical + vbOKOnly, "Date Error"
    3.     Exit Sub
    4. End If
    5.  
    6. If Not IsDate(Me.OYear) Or Not IsDate(Me.nDate) Then
    7.   MsgBox "At least one Invalid Date", vbCritical + vbOKOnly, "Invalid Date Error"
    8.     Exit Sub
    9. End If
    10.  
    11. If CDate(Me.OYear) <= CDate(Me.nDate) Then
    12.   MsgBox "Oldest date must be less than Newest date", vbCritical + vbOKOnly, "Date Error"
    13.     Exit Sub
    14. End If
    15.  
    16. If Me.chkShowCredits Then
    17.   DoCmd.OpenReport "Summary with Credits", acViewPreview
    18. ElseIf Me.chkNoCredits Then
    19.   DoCmd.OpenReport "Summary With No Credits", acViewPreview
    20. Else
    21.   MsgBox "Select an option to show or not to show credits in the report", _
    22.           vbCritical + vbOKOnly, "Data Missing"
    23. End If
Jun 13 '10 #8
@ADezii
Thank You ADezii
Jun 13 '10 #9
I Here To Learn.

Thank You For All.
Jun 13 '10 #10
Jerry Maiapu
259 100+
Thank you all for assistance. Post#8 worked.
Jun 15 '10 #11
Jerry Maiapu
259 100+
msquared's solution post#6 was interesting too.

And yes thanks ahmedtharwat19 for the attachment(post#7).

Thanks all.

I am happy to be part of this genius community.

Much Regards
Jun 17 '10 #12

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

Similar topics

1
by: jj | last post by:
Hi All I wan't to create a PDF document automatically from Access, and I have tried to use the way Keri Hardwick explains on: http://www.mvps.org/access/reports/rpt0011.htm But when the code...
0
by: Robert McGregor | last post by:
Using the follwing code and getting the error message: Run time error '2455': You entered an expression that contains an invalid reference to the property MaxRecButton. My code just...
0
by: SheldonMopes | last post by:
I have a command button on a form that changes the filter and order conditions on a subform (the subform is based on a query). Sometimes, if I click the button again immediately after clicking on...
20
by: Crayola465 | last post by:
I have been trying to figure this out for a couple weeks and after reading every post in the forum about the subject I have not found anything that works. I have two tables; 1) has company...
2
by: Asle | last post by:
Hi, I have a form called Customer and another form called Loan.. the Loan Details has to be entered every month until it is closed. I have designed a form such that, the user goes to the...
4
by: JFKJr | last post by:
HI!, I am trying to import an excel file to an Access table using the following code, but I am getting "Run-time error '31519':You cannot import this file" error. Function Import_ExcelFile()...
1
by: dee | last post by:
I have a form 'FmMessages" and a form 'FmLeads'. 'FmMessages', through code, opens 'FmMessages" if it is not already open. It then sets focus on 'FmLeads' and runs the following code: Dim rst...
5
by: Sep410 | last post by:
Hi all, Here is my code: Private Sub Command12_Click() Dim strSql As String strSql = "Delete from tbl_city where CityId=" & Val(Me!txtEmail.Text) & ";" Set cn =...
3
by: ramprat | last post by:
Hi Sorry to keep asking questions but I keep getting a run-time error 2001 "you canceled the previous operation" error whenever the code in the Dlookup line is reached. I have a table called...
5
by: mufc4life | last post by:
Hi, actually I'm creating a database for some coursework at school. It's basically about a booking system and how I book hardware in and out of the school for students who need the hardware. I've...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.