Wrox Programmer Forums
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 11th, 2008, 03:47 PM
Authorized User
Join Date: Jun 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with Dlookup

I am trying to grab a record id using Dlookup the issue i am running into is that I am trying to get the ID by matching a string
RecID=Dlookup("RecID","Table","String=" & sting)

This works fine until the string has an "'" in it, I know why this is an issue I just can't seem to figure out a way to get around it.
Any help would be great!!


Old January 11th, 2008, 06:52 PM
Friend of Wrox
Join Date: Jul 2005
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts

Assuming Access 2000 or later:


RecID=Dlookup("RecID","Table","String='" & Replace(string, "'", "''" & "'")

"Hi Tech Coach"
Access Based Accounting/Business Solutions developer.

Similar Threads
Thread Thread Starter Forum Replies Last Post
dlookup problem alemok Access 0 April 17th, 2008 02:50 AM
Dlookup and variables Jaqx Access 3 September 29th, 2006 06:47 AM
Help with DLookup Devilboy13 Access VBA 4 August 30th, 2006 02:48 PM
Help - Dlookup function kk_sg Access VBA 3 August 23rd, 2006 11:30 AM
DLookup Teqlump Access VBA 1 August 9th, 2006 11:48 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.