Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 08-24-2007, 09:31 AM
Novice
 
Join Date: Aug 2007
Posts: 1
ericargent
Default Need help - Record set based on a program variable

Hi
I am quite new to VBA and access 2003 and I know this should be very easy.

I am trying to open a record set where the critieria is based on a program variable.
For example


<statements to provide connection to table>


Dim productionrun as string
productionrun = "1234"

rst.Open "select * from specimendata where runnumber = productionrun ", conn, adOpenForwardOnly, adLockReadOnly


I am hopeing this would select all records from the table specimendata where the field runnumber is equal to that of the variable productionrun (in this case 1234).

If I substitute productionrun for '1234' it works fine, I just can't seem to pass the variable across.

Any ideas on how best to do this.
Thanks
Reply With Quote
  #2  
Old 09-19-2007, 06:57 PM
jya jya is offline Windows XP Access 2007 (version 12.0)
Competent Performer
 
Join Date: Sep 2007
Location: Chicagoland
Posts: 109
jya is an unknown quantity at this point
Default

You need to move the end quote before your variable.

rst.Open "select * from specimendata where runnumber = " & productionrun, conn, adOpenForwardOnly, adLockReadOnly
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ticketing program for community theater Bill Database Design 1 08-12-2009 09:00 PM
Passing a value from a variable to an update query MUKUDU99 Programming 0 08-24-2008 09:14 PM
Variable question synapse5150 Programming 1 07-09-2008 06:17 AM
Deleting Record Contents, not complete record... Charles Waters Access 2 06-24-2008 10:00 AM
pass a variable to the MsgBox function 3dmgirl Programming 2 04-19-2007 05:14 AM


All times are GMT -8. The time now is 02:42 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.