My sub just leaves me with #Name?

ninja_imp

Registered User.
Local time
Today, 13:03
Joined
Apr 11, 2006
Messages
50
I have just really started looking at using VB to run main functions in my forms to ease up a bit of processing time. I used to have a sum which gave a total on screen for the selected customer but this would never write to the main table so i was unable to use it at a later date without having to run the calculation again - So i built this module below but the field it is meant to update only ever has '#Name?' in it - i have checked all names but just can seem to figure it out - the code is below:

Public Sub MyPaymentTotal()
On Error GoTo MyPaymentTotal_Err
Dim DetailRst As DAO.Recordset
Dim CurDB As Database
Dim PaymentTotal As Currency

Set CurDB = CurrentDb
PaymentTotal = 0

' open read only recordset to total up all amounts
Set DetailRst = CurDB.OpenRecordset("Select Sum(PubTotal)FROM Frm_Customer WHERE CustRef = Me.CustRef")


If Not DetailRst.EOF Then
PaymentTotal = Nz(DetailRst!DailyTotal, 0)
End If
DetailRst.Close

Me!Payments = PaymentTotal

MyPaymentTotal_Exit:
Exit Sub

MyPaymentTotal_Err:
MsgBox Err.Description
Resume MyPaymentTotal_Exit

End Sub


Any help greatly appreciated
 
First, you should declare CurDb as DAO.database so that it is not confused with ADO

Second, what is your control source for the textbox
 
Last edited:
As posted by Microsoft, "All of the domain functions are based on the same query (over the underlying dynaset). If one of the bound functions on the form has a binding error, all of the functions on the form will return an error." So find which control has the error and remove it.
 
the control source for the textbox is on the main customer table.

would this be one of the controls on the main form? If so, how do i find out which one has the error on it?

cheers
 

Users who are viewing this thread

Back
Top Bottom