Solved

Change Line of Code in Module (using Access 2000)

Posted on 2011-03-10
6
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

739 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