Object variable or with block variable not set Error

SmallTime

Registered User.
Local time
Today, 00:32
Joined
Mar 24, 2011
Messages
246
This code in the onformat of a report header previously worked fine in A2K but 2010 throws an error message if the date field in the form is empty.

If IsNull(Forms![FrmAccounts]![TxtStartDate]) Or Forms![FrmAccounts]![TxtStartDate] = "" Then
Me.LblHeader.Caption = "Order Data"
Else
Me.LblHeader.Caption = "Order Data for " & Forms![FrmAccounts]![TxtStartDate]
End If

Error message reads
“Run-time error 91
Object variable or with block variable not set”

Anyone know why this should be
 
Change your code to this:
Code:
If [B][COLOR=red]Len([/COLOR][/B]Forms![FrmAccounts]![TxtStartDate][B][COLOR=red] & vbNullString) = 0[/COLOR][/B] Then
   Me.LblHeader.Caption = "Order [URL="http://www.access-programmers.co.uk/forums/showthread.php?t=209133#"][COLOR=darkgreen]Data[/COLOR][/URL]"
Else
   Me.LblHeader.Caption = "Order Data for " & Forms![FrmAccounts]![TxtStartDate]
End If
 
Thank you so much Bob

Changing from 2000 to 2010 sometimes make me feel like an absolute nitwit

Kind Regards
SmallTime
 

Users who are viewing this thread

Back
Top Bottom