#Error - totally baffled

jsonne

New Member
Joined
May 6, 2004
Messages
40
:oops:
I created the database on my "U" drive which is linked to the "local-user specific" network, but when I copy the database to the "F" drive which is a "shared" network the following code

=TotalCalls(nz([contactid],0)) returns the #Error.

I do not understand as I have another label with the following code

=TotalSamples(nz([ContactID],0)) and it returns no error.

Any thoughts? Totally frustrated...........and the person who needs this database is having a hairy!

Thanks everyone.
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Are "TotalCalls" and "TotalSamples" custom functions you have written? If so, how are the defined?
 
Upvote 0
The code was written by someone else on the board. The code is in the main form so that when the subform (call listing subform) for # of calls has new information and they press the F9 key it updates the main form. The same goes for the # of samples (workorder subform).

I hope this is what you wanted as I'm not very good at programming - yet.

Here is the code:

Option Compare Database

Function IsLoaded(ByVal strFormName As String) As Integer
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function

Function TotalSamples(pContactID As Long) As Integer

Dim db As Database
Dim LSQL As String
Dim Lrs As Recordset

Set db = CurrentDb()

'Retrieve the number of samples for the ContactID (represented by pContactID)
LSQL = "select sum([# of Samples]) from Workorders"
LSQL = LSQL & " where ContactID = " & pContactID

Set Lrs = db.OpenRecordset(LSQL)

'Records are found
If (Lrs.EOF = False) And (IsNull(Lrs(0)) = False) Then
TotalSamples = Lrs(0)
Else
TotalSamples = 0
End If

End Function

Function TotalCalls(pContactID As Long) As Integer

Dim db As Database
Dim LSQL As String
Dim Lrs As Recordset

Set db = CurrentDb()

'Retrieve the number of calls for the ContactID (represented by pContactID)
LSQL = "select count(*) from Calls"
LSQL = LSQL & " where ContactID = " & pContactID

Set Lrs = db.OpenRecordset(LSQL)

'Records are found
If (Lrs.EOF = False) And (IsNull(Lrs(0)) = False) Then
TotalCalls = Lrs(0)
Else
TotalCalls = 0
End If

End Function


Thanks for any ideas! :rolleyes:
 
Upvote 0
=TotalCalls(nz([contactid],0)) returns the #Error.

I do not understand as I have another label with the following code

=TotalSamples(nz([ContactID],0)) and it returns no error.

I noticed that ContactID is capitilsed in one and not the other, this may mean nothing but is worth a lokk.

I would substitute a valid number for TotalCalls(nz([contactid],0)) to see if the error is in the code or in the call. something like TotalCalls(123456) or whatever number you are using.

This will help narrow the search for the problem.

peter
 
Upvote 0
:oops:

This problem is only happening on one machine running Windows 2000 - whereas everyone else is running Windows XP. Could this be the culprit?
 
Upvote 0
Could be a long shot, but go to their machine and check for missing references. You may have enabled a library that they do not have -- for example, you are most likely using version 10 of a library for which they only have 9. Or your ADO lirary is one version higher, or...

(In any module, Tools | References)

Denis
 
Upvote 0
Have you tried stepping through the code to discover where the error is actualy occuring?

Peter
 
Upvote 0

Forum statistics

Threads
1,221,780
Messages
6,161,887
Members
451,730
Latest member
BudgetGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top