Solved

Runtime error 2427, expression has no value

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

809 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