Results 1 to 6 of 6
  1. #1
    meet_binay is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    5

    defining and setting value of a varible?


    Hi, how 2 declare and set values in the access query?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Queries don't have variables; what is it you're trying to accomplish?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    meet_binay is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    5
    hi paul , I am trying to get some results from joining the tables and do some calculations on it. The problem is that I can't write multiple "select" or "insert" and "udate " in a single query.
    Besides i found some where the syntax like

    "PARAMETERS x IEEEDouble;
    INSERT INTO CUSTOMER_DETAILS
    VALUES ('xxx', 'YYY', '11111111', 'SASA');
    " .
    Doesn't give a syntax error but can's set a value for x.

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    binay,

    that really didn't answer Paul's question. So what is it that you want to do again? INSERT values into a table? I thought you said that you wanted to perform calculations on your data? That would probably not involve an INSERT statement.

  5. #5
    meet_binay is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2011
    Posts
    5
    Hi Adam.
    First i want to select sum of a row found from multiple tables joins. I can do that , no problem. But then i want to insert some values in another table based on the values of the first select.
    I can't write a insert statement after a select statement. So i was wondering whether i can store that value in a variable by writing the select statement in the "set var= select...." of that variable.
    Also i need if statement to check the value of the sum.
    Doing these things in sql query is very simple but in access???

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by meet_binay View Post
    Hi Adam.
    First i want to select sum of a row found from multiple tables joins.
    summing rows have to be done in separate fields. No other way to do it, really.

    Quote Originally Posted by meet_binay View Post
    But then i want to insert some values in another table based on the values of the first select.
    I can't write a insert statement after a select statement. So i was wondering whether i can store that value in a variable by writing the select statement in the "set var= select...." of that variable.
    ummm...NO.

    so you want to insert the resulting SUM value into a new dataset, right? You can do that 2 ways easily:

    • get the sum through a function and write the result of it into the INSERT statement, or...
    • write one static query and reference it with the second query. One statement per query


    I am not sure if you can include a function inside of a VALUES() statement, but you can try it. for instance, try:

    Code:
    INSERT INTO newtable (field) VALUES (myfunction(argument))

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

Similar Threads

  1. Need help in setting up a DB construction
    By ClownKiller in forum Database Design
    Replies: 5
    Last Post: 01-06-2011, 06:21 PM
  2. Setting value of a formfield
    By toddbuckles in forum Programming
    Replies: 7
    Last Post: 12-27-2010, 09:46 PM
  3. defining Criteria between two dates
    By tamu46 in forum Queries
    Replies: 1
    Last Post: 12-04-2010, 11:58 PM
  4. Setting Value for Each Row in Subform
    By swimmermx in forum Forms
    Replies: 11
    Last Post: 07-21-2010, 05:25 PM
  5. Setting up new database
    By mduplantis in forum Database Design
    Replies: 1
    Last Post: 06-23-2010, 11:07 AM

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