Results 1 to 7 of 7
  1. #1
    mohammadyou is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    4

    Use Parameter in select statement (Sql in Access)

    Hi everybody
    I'm newbie in access and I wanna know how we can use a Parameter in Select statement (SQL view)?


    ( actually I want to get a number from user and use it for selecting some random records)
    tanks in advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Does this help http://office.microsoft.com/en-us/ac...001117077.aspx

    SELECT * FROM tablename WHERE fieldname = [enter number];
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    mohammadyou is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    4
    Thank june7 for your reply

    I use parameter number in this code :

    Code:
     SELECT TOP 5 * FROM [QuestionTable] ORDER BY rnd(INT(NOW*primarykey)-NOW*primarykey)


    Instead of number 5 I want to get a number from a user.
    what should I do?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I just tried to build query with a pop up parameter prompt for the number and it doesn't work.

    Why do you need to have this number dynamic?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    mohammadyou is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    4
    As I told you. I'm beginner in access and don't like to use VB code.
    I'm considering to build a Database for pulling some questions out from a question repository, base on chapter of course.
    so I should get a number from user who want to prepare an exam and tell how many percentage of this exam must from which chapter.
    e.g: an exam with 20 questions that 80% of those question must from Chapter one and 20% Chapter two.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Apparently cannot be dynamic in an Access query object. That means using code (VBA certainly, doubt macro can do this) to construct an SQL statement and setting the RecordSource property of form or report or the definition of a query with QueryDefs collection.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    mohammadyou is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    4
    Thank you for your Help

Please reply to this thread with any new information or opinions.

Similar Threads

  1. use parameter in field name of select query
    By focosi in forum Queries
    Replies: 2
    Last Post: 02-11-2012, 10:34 AM
  2. Need a select statement
    By gahawy in forum Queries
    Replies: 5
    Last Post: 01-15-2011, 04:02 PM
  3. select statement
    By jellybeannn in forum Access
    Replies: 5
    Last Post: 08-13-2010, 05:21 AM
  4. Replies: 1
    Last Post: 05-13-2010, 10:37 AM
  5. Parameter Query: Select From A List?
    By catbob in forum Queries
    Replies: 4
    Last Post: 02-08-2010, 08:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums