Solved

Change Line of Code in Module (using Access 2000)

Posted on 2011-03-10
6
184 Views
Last Modified: 2012-05-11
I have function listed below in the code section.

Would you please help to change following line "Where [LoanID]=" & sVar & "")

This line was correct when I have LoanID with Type Number (Size Double) in the table.
Currently Data Type in Table changed from Number to Text.  How can I adjust line because when I run function I have run time error "No current record".  Once I changed Data Type back to Number everything is working.  Thank you.
Function ConcatVar(sVar As Variant) As String
Dim rs As DAO.Recordset, s As String

Set rs = CurrentDb.OpenRecordset("select * From [Combined-Tax-Data] Where [LoanID]=" & sVar & "")

    rs.MoveFirst
 
    Do Until rs.EOF
      s = s & rs("[Tax_Explanation]") & ";"
      rs.MoveNext
    Loop

    ConcatVar = Left(s, Len(s) - 1)
End Function

Open in new window

0
Comment
Question by:maximyshka
6 Comments
 
LVL 33

Accepted Solution

by:
jppinto earned 500 total points
ID: 35100496
Set rs = CurrentDb.OpenRecordset("select * From [Combined-Tax-Data] Where [LoanID]='" & sVar & "'")

0
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 500 total points
ID: 35100507
Please note that I've added two ' (one after the [LoanID] an one between the "")
0
 
LVL 9

Expert Comment

by:sshah254
ID: 35100536
Or

Set rs = CurrentDb.OpenRecordset("select * From [Combined-Tax-Data] Where [LoanID]=""" & sVar & """")

Single or double apostrophes - either one should work fine.

Ss
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 75
ID: 35100577
try this:

CurrentDb.OpenRecordset("select * From [Combined-Tax-Data] Where [LoanID]=" & Chr(34) &  sVar & Chr(34) )

mx
0
 
LVL 75
ID: 35100891
Please keep in mind that contrary to popular belief ... single quotes are problematic in Access criteria expressions ... because in this case for example ... if sVar  happens to contain a single quote ... aka apostrophe ... like O'Brien etc ... your expression will fail.  Using double quotes - Chr(34) avoids this issue.

mx
0
 

Author Comment

by:maximyshka
ID: 35100915
Thanks MX.  Sorry about points
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now