Solved

Runtime error 2427, expression has no value

Posted on 2004-08-16
4
378 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

920 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

15 Experts available now in Live!

Get 1:1 Help Now