Solved

Runtime error 2427, expression has no value

Posted on 2004-08-16
4
386 Views
Last Modified: 2013-12-25
Hi,
  i have 2 buttons in a form in an Access DB which have pretty much the same code to open 2 different reports. Now, one report opens but the other gives a runtime error. Here is the code

Private Sub cmdPrintReciept_Click()

'DoCmd.Requery

If IsNull(Me.txtorID) Then
    MsgBox "The order must have an order number before an reciept can be printed.", , "MITC Message"
Else
    '*-- Save the record before generating the report
    DoCmd.RunCommand acCmdSaveRecord
   
    DoCmd.OpenReport "rptReciept", acViewPreview, , "orID = " & Me.txtorID
End If


End Sub



Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim r As Single
   
 <<<ERROR>>>>   r = Me.txtCount Mod 2
   
    If r = 0 Then
        Me.Box1.Properties("backcolor") = 16777164
    Else
        Me.Box1.Properties("backcolor") = vbWhite
    End If
   
End Sub
0
Comment
Question by:BrijBhasin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 11813855
What is the value of Me.txtCount  at the time of the error?

Leon
0
 

Author Comment

by:BrijBhasin
ID: 11814021
The default value in the Control source =1, I guess the value depends on the no. of rows in the report.
0
 
LVL 29

Accepted Solution

by:
leonstryker earned 250 total points
ID: 11814218
Place a break point on this line and see if there is actaully a value there then this line is being executed.

As a test try:

r = CInt(Trim(Me.txtCount.Text))

And:

r = CInt(CInt(Me.txtCount.Text) Mod 2)

Another thing I seem to remeber in Access, is make sure the control has focus before doing this:

Me.txtCount.SetFocus
r = Me.txtCount.Text Mod 2

Leon
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11814665
What error does it give ?
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question