Solved

Runtime error 2427, expression has no value

Posted on 2004-08-16
4
376 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
  • 2
4 Comments
 
LVL 29

Expert Comment

by:leonstryker
Comment Utility
What is the value of Me.txtCount  at the time of the error?

Leon
0
 

Author Comment

by:BrijBhasin
Comment Utility
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
Comment Utility
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
Comment Utility
What error does it give ?
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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 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…

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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now