?
Solved

Runtime error 2427, expression has no value

Posted on 2004-08-16
4
Medium Priority
?
391 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 1000 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

762 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