PDA

View Full Version : Error Occurred after Converting v2002 to v2010



winxmun
01-11-2016, 04:05 AM
Hi, I have the following VBA saved in the report, and the report will have a field to display "Names" based on the VBA. This was working fine in v2002. However doesn't work in v2010. Anybody able to help? thank you.


Option Compare Database
Public applicants As String

Option Explicit
---------------------------------------------------------------
Private Sub Report_Open(Cancel As Integer)
Dim dbs As dao.Database
Dim rstLM As dao.Recordset
Dim sSQLM As String
Set dbs = CurrentDb()
Set rstLM = dbs.OpenRecordset("MainRecords", dbOpenDynaset)
sSQLM = "[LNo] Like '" & Forms!Enquiry!LNo & "'"
rstLM.FindFirst sSQLM
If rstLM.NoMatch Then
MsgBox "Number Not Found"
Exit Sub
Else
'------------To get the Borrower(s)string--------------
If Not IsNull(rstLM!Name1) Then
Names = rstLM!Name1
End If
If Not IsNull(rstLM!Name2) Then
Names = Names & "/ " & rstLM!Name2
End If
If Not IsNull(rstLM!Name3) Then
Names = Names & "/ " & rstLM!Name3
End If

End If




End Sub

ranman256
02-05-2016, 06:11 AM
you don't need this code in a report. Access is already in DAO.
put this IF in the query and just display the field.

no code needed.