Run-Time Error 2427 (1 Viewer)

poohbear2012

Registered User.
Local time
Today, 20:03
Joined
Jan 8, 2012
Messages
30
I am encountering Run-time error 2427 "You entered an expression that has no value". The line in bold below is the line causing the issue.

The txtcount field on the form is =Count([tbldetails.CustomerNumber])
there are two identically name fields in two tables, hence why the table name is at the front. Not sure if this where the error lies.


Option Compare Database
Private Sub btnsendemail_Click()

If Me.txtcount = "" Then
MsgBox "There are no actions to be undertaken"
Else
On Error GoTo handdler

Regards
Trisha
 

tehNellie

Registered User.
Local time
Today, 20:03
Joined
Apr 3, 2007
Messages
751
[tbldetails].[customernumber] is the correct formatting for specifying a table and column-name.
 

poohbear2012

Registered User.
Local time
Today, 20:03
Joined
Jan 8, 2012
Messages
30
Hi

Thanks for that. The error has stopped popping up but now nothing happens at all when the button that the VBA associated to is clicked. Macros are enabled and other buttons on the page work fine.


Regards
Trisha
 

tehNellie

Registered User.
Local time
Today, 20:03
Joined
Apr 3, 2007
Messages
751
Stick a breakpoint on the code behind the button (F9 or click in the margin where you want the code to break) step through it line at a time (F8 in the IDE) and have a look at the values that your code is depending on as it runs. The Locals and Watch windows are helpful at this point to keep tabs on what values your variables currently represent.

Your test on the count, for example, is looking for "" but the count should be returning 0 if there are no records so the test should never be true.

If your code snippet is indicative, I'd also recommend adding

Code:
Option Explicit

To your modules along with Option Compare Database, it makes bug fixing much easier as it'll pick up issues along the lines of:

Code:
dim strMessage as string
dim intExample as integer 

strMes[b]s[/b]sage = "I've typoed this variable"

intExample = "this is text instead of an integer"

strValue = "I'm trying to use a variable I haven't declared"
 

Users who are viewing this thread

Top Bottom