Connecting Tech Pros Worldwide Forums | Help | Site Map

Getting Rid of #Error

Member
 
Join Date: Mar 2008
Posts: 41
#1: Mar 15 '08
Hello,

I need help on getting rid of #Error in my fields on a form when no data exist. I was using the below formula:

="" & [System]

and when #Error showed I switched over to

=IIf(IsNull([System])," ",[System])

and that came up with the same results. If data exist it works fine but when data is not there I want it to be blank or say "No data exist".

What formula can I use in the control source to fix this. Any assistance would be most appreciative.

Thanks

missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,103
#2: Mar 15 '08

re: Getting Rid of #Error


What exactly is [System]? What Datatype?

Welcome to TheScripts!

Linq ;0)>
Expert
 
Join Date: Mar 2008
Location: Firestone, CO
Posts: 112
#3: Mar 15 '08

re: Getting Rid of #Error


I'm trying to duplicate this error to see if I can fix it, what data type is your [System] Column?
Member
 
Join Date: Mar 2008
Posts: 41
#4: Mar 16 '08

re: Getting Rid of #Error


Quote:

Originally Posted by janders468

I'm trying to duplicate this error to see if I can fix it, what data type is your [System] Column?

Sorry about the slow response but two are of text and one is Date/Time.

It looks like this

="of " & [StudentCompany]

="" & [System]

=" on " & [GraduationDate]

Let me know what you come up with.

Thanks
Member
 
Join Date: Mar 2008
Posts: 41
#5: Mar 16 '08

re: Getting Rid of #Error


Quote:

Originally Posted by missinglinq

What exactly is [System]? What Datatype?

Welcome to TheScripts!

Linq ;0)>

I'm sorry Linq, but System is one of the fields from table1 used on the form and DataType is text.

Thanks for the fast response sorry couldnt say the same but step out a bit, didnt think anyone would respond back so quick.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 16,173
#6: Mar 16 '08

re: Getting Rid of #Error


David,

I've tried various approaches but was unable to duplicate your problem in any of them I'm afraid.

It appears there's some quite fundamental information that you haven't included in the question. I can't tell you what it may be, but this isn't standard behaviour in a form to report #Error simply because a field has no data.
Member
 
Join Date: Mar 2008
Posts: 41
#7: Mar 16 '08

re: Getting Rid of #Error


Quote:

Originally Posted by NeoPa

David,

I've tried various approaches but was unable to duplicate your problem in any of them I'm afraid.

It appears there's some quite fundamental information that you haven't included in the question. I can't tell you what it may be, but this isn't standard behaviour in a form to report #Error simply because a field has no data.


NeoPa,

I miss quoted before in saying it was a form, in fact it is a report. I am missing something but cant figure it out.

David
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 16,173
#8: Mar 16 '08

re: Getting Rid of #Error


I think the matching answer is :
Expand|Select|Wrap|Line Numbers
  1. =IIf(IsError([System]),'',[System])
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 16,173
#9: Mar 16 '08

re: Getting Rid of #Error


Should the question rather be though :
How do I stop a report from running if there are no matching records?

If so, the answer is that there is an On No Data event.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_NoData(Cancel As Integer)
  2.  
  3. End Sub
This allows code to run informing the operator of the situation as well as allowing the report to be cancelled entirely (Set Cancel to True before exiting procedure).
Member
 
Join Date: Mar 2008
Posts: 41
#10: Mar 16 '08

re: Getting Rid of #Error


Quote:

Originally Posted by NeoPa

Should the question rather be though :
How do I stop a report from running if there are no matching records?

If so, the answer is that there is an On No Data event.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_NoData(Cancel As Integer)
  2.  
  3. End Sub
This allows code to run informing the operator of the situation as well as allowing the report to be cancelled entirely (Set Cancel to True before exiting procedure).

Thanks NeoPa,

Good solution but how do you set it to true.

David
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 16,173
#11: Mar 17 '08

re: Getting Rid of #Error


At its simplest :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_NoData(Cancel As Integer)
  2.   Cancel = True
  3. End Sub
Scott Price's Avatar
Moderator
 
Join Date: Jul 2007
Location: Seattle, WA
Posts: 1,314
#12: Mar 17 '08

re: Getting Rid of #Error


Have a look at Avoid #Error in Form/Report with no data on Allen Browne's website.

Regards,
Scott
Member
 
Join Date: Mar 2008
Posts: 41
#13: Mar 17 '08

re: Getting Rid of #Error


Quote:

Originally Posted by Scott Price

Have a look at Avoid #Error in Form/Report with no data on Allen Browne's website.

Regards,
Scott


Thanks for the information.

David
Member
 
Join Date: Mar 2008
Posts: 41
#14: Mar 17 '08

re: Getting Rid of #Error


Quote:

Originally Posted by NeoPa

At its simplest :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Report_NoData(Cancel As Integer)
  2.   Cancel = True
  3. End Sub

NeoPa,

Thanks, that worked perfectly I have just one more question. How can you make Microsoft Access close the same time the database closes.

David
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 16,173
#15: Mar 17 '08

re: Getting Rid of #Error


There's no really direct way, but if you cause an invisible form to open when you open the database (Tools / Startup...) then you can leave it running in the background while the database is open.

In the Form_Close() event procedure you can then call a close of Access itself :
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Close()
  2.   Call Application.Quit
  3. End Sub
Member
 
Join Date: Mar 2008
Posts: 41
#16: Mar 18 '08

re: Getting Rid of #Error


NeoPa,

I can definitely say you are the expert. Everything work like you said and I appreciate your help. I am just about done. Can you throw me another bone on another stump I hit. ...
** Edit **
Question asked in new thread - see next post.

David.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 16,173
#17: Mar 18 '08

re: Getting Rid of #Error


Thank you for your comments David.

I have split off the extra question into its own thread (Select Report to Open by CheckBox) as explained in the thread.
Reply