N
Nick T
Hi,
On my customer visit log db, i have a command button which when clicked
displays in text boxes on my form certain details about the customer for whos
record i am viewing. I can scroll through all records (1 record for each
customer) using my mouse.
However, when i get to the end of all the records, the last record is blank
and has (AutoNumber) displayed in my 'customer id' text box. I know this is
effectively the next record to be filled in & the autonumber will become the
next sequential no. in my table.
Anyway, if on this record, and i click my command button (as above), i get a
Syntax error message. This i can understand, and isnt a problem for me,
however if a user does this, it could effectively give them access to my code
if the 'Debug' button on the error window is clicked.
How can i avoid this??
My code behind my command button is as follows:
Private Sub Command173_Click()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("CustomerVisitLogQuery", dbOpenDynaset)
With rst
.FindFirst "[Customer ID] = " & Me.CustomerID
If .NoMatch Then
MsgBox "The purchase Log for " & Me.FirstName & " contains no
data"
Me.TotalSpend = ""
Me.AverageSpend = ""
Me.NoofVisits = ""
Else
Me.TotalSpend = ![Sum Of Spend Value (£)]
Me.AverageSpend = ![Avg of Spend Value (£)]
Me.NoofVisits = ![Count of Customer Visit Log]
End If
Set rst = CurrentDb.OpenRecordset("Customer Visit Log", dbOpenDynaset)
With rst
.FindLast "[Customer ID] = " & Me.CustomerID
If .NoMatch Then
Me.LastSpend = ""
Me.LastVisit = ""
Else
Me.LastVisit = ![Date of Visit]
Me.LastSpend = ![Spend Value (£)]
End If
.Close
End With
Set rst = Nothing
Sorry if this Q is a bit long winded!!
On my customer visit log db, i have a command button which when clicked
displays in text boxes on my form certain details about the customer for whos
record i am viewing. I can scroll through all records (1 record for each
customer) using my mouse.
However, when i get to the end of all the records, the last record is blank
and has (AutoNumber) displayed in my 'customer id' text box. I know this is
effectively the next record to be filled in & the autonumber will become the
next sequential no. in my table.
Anyway, if on this record, and i click my command button (as above), i get a
Syntax error message. This i can understand, and isnt a problem for me,
however if a user does this, it could effectively give them access to my code
if the 'Debug' button on the error window is clicked.
How can i avoid this??
My code behind my command button is as follows:
Private Sub Command173_Click()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("CustomerVisitLogQuery", dbOpenDynaset)
With rst
.FindFirst "[Customer ID] = " & Me.CustomerID
If .NoMatch Then
MsgBox "The purchase Log for " & Me.FirstName & " contains no
data"
Me.TotalSpend = ""
Me.AverageSpend = ""
Me.NoofVisits = ""
Else
Me.TotalSpend = ![Sum Of Spend Value (£)]
Me.AverageSpend = ![Avg of Spend Value (£)]
Me.NoofVisits = ![Count of Customer Visit Log]
End If
Set rst = CurrentDb.OpenRecordset("Customer Visit Log", dbOpenDynaset)
With rst
.FindLast "[Customer ID] = " & Me.CustomerID
If .NoMatch Then
Me.LastSpend = ""
Me.LastVisit = ""
Else
Me.LastVisit = ![Date of Visit]
Me.LastSpend = ![Spend Value (£)]
End If
.Close
End With
Set rst = Nothing
Sorry if this Q is a bit long winded!!