Results 1 to 4 of 4
  1. #1
    ksmith is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2010
    Posts
    59

    Select statement syntax?

    Thanks in advance for your help.



    I have a form that I am using to enter a lot of info into couple different tables.

    I am calling the function below and wanting to retreive the 'value' of field AMOUNT in TABLE; tblShipping.

    txtCatalogModelNUmber is an unbound text box on the form that has the Catalog Model Number that the user will enter.

    Public Function FindAmount()
    Dim strsql As String
    Dim strMyString As String

    strMystr = Me.txtCatalogModelNumber

    strsql = "Select Amount from tblShipping " & _
    "Where CatalogModelNumber = " & Chr$(34) & strMystr & Chr$(34)

    Debug.Print strsql
    End Function

    Select Amount from tblShipping Where CatalogModelNumber = "263"
    The above statement is what is in the immediate window.

    263 is what I entered on the form to start the search.

    The questions that I have are;
    1. Is this the correct way to do this?
    2. How do I 'store' the value that is in the AMOUNT field to a text box on the form?
    3.Also I need to be able to subtract another Quantity (on the form) from this AMOUNT and replace AMOUNT with that calculation.

    Thanks for the help.

  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,521
    1) It's a start. You would then open a recordset on that SQL to actually get the value.

    2) As in 1 above, you'd open a recordset on the SQL. You might find DLookup() simpler to use at first.

    3) You could execute an update query from code.

    Your question implies that you're trying to maintain an inventory quantity on hand or something to that effect. In general, I'd recommend against it. There's a discussion on the topic:

    http://allenbrowne.com/AppInventory.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ksmith is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jun 2010
    Posts
    59
    Thanks for info I will give it a try. It's nice to know there are MVP's ready to help a struggling Access programmer.

    Thanks again.
    KSmith

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    No problemo; post back if you get stuck.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Use of COLLATE statement in SELECT clause
    By zurek in forum Queries
    Replies: 7
    Last Post: 03-16-2011, 06:46 AM
  2. Replies: 1
    Last Post: 05-13-2010, 10:37 AM
  3. What is wrong with my SQL Select statement?
    By John2810 in forum Programming
    Replies: 2
    Last Post: 04-01-2010, 10:30 AM
  4. Syntax Contains Problem
    By pimlicosnail in forum Forms
    Replies: 9
    Last Post: 02-18-2010, 12:16 PM
  5. Syntax Error In Insert Into Statement
    By frankvfox in forum Queries
    Replies: 1
    Last Post: 09-09-2008, 12:35 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