Solved

Change Line of Code in Module (using Access 2000)

Posted on 2011-03-10
6
185 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

929 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

20 Experts available now in Live!

Get 1:1 Help Now