Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2007

Tip: Looking for answers? Try searching our database.

Create recordset programatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
George Stevenson - 24 Jan 2007 20:04 GMT
I'm using Access2000.  I need to be able to work with a subset of records in
my main database of public records from the register of deeds.  One of the
indices is by Book/Page.  I need to be able to determine what records might
already exist in the database with an existing book/page when a new record
is to be added in my add routine. The existing DB name is GES.

I want to be able to create a small recordset in program code with a select
statement that uses the book/page that is on an incoming transaction.  In
the example below, I've hard coded the book page for illustrative purposes.

Here is what I'm trying to do, could someone point the way so that I can
flesh this out more?

Dim myBook As String, myPage As String, rstGESBkPg As Recordset

myBook = "6917"
myPage = "647"
Set db = CurrentDb()
Set rstGESBkPg = New Recordset
rstGESBkPg.Open "Select * From GES where ges.fcdtbook =" & myBook & " and
ges.fcdtpage=" & myPage & "", _
   CurrentProject.Connection, adOpenKeyset, adLockOptimistic

---------------
The code above gives me a "Data type mismatch in the criteria expression"
The book/page fields in the GES database are text
Don't I need to open the GES db and specify the book/page Index to be used
for the select statement?
chris.nebinger@gmail.com - 24 Jan 2007 23:39 GMT
If the fields are text, you need to have single quotes areound the
fields

rstGESBkPg.Open "Select * From GES where ges.fcdtbook ='" & myBook & "'
and
ges.fcdtpage='" & myPage & "'",

That is:

where ges.fcdtbook = [SINGLEQUOTE][DOUBLEQUOTE] & myBook &
[DOUBLEQUOTE][SINGLEQUOTE] and ges.fcdtpage =
[SINGLEQUOTE][DOUBLEQUOTE] & myPage &
[DOUBLEQUOTE][SINGLEQUOTE][DOUBLEQUOTE]

hth,

Chris Nebinger

> I'm using Access2000.  I need to be able to work with a subset of records in
> my main database of public records from the register of deeds.  One of the
[quoted text clipped - 24 lines]
> Don't I need to open the GES db and specify the book/page Index to be used
> for the select statement?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.