Solved

Change Line of Code in Module (using Access 2000)

Posted on 2011-03-10
6
186 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create tables in access db (2016)  using vba 13 41
Modal form 11 30
Display label on subreport when NO DATA on subreport 4 22
Access Open Report with SQL Parameter 11 30
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

776 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