Results 1 to 13 of 13
  1. #1
    Join Date
    Sep 2010
    Posts
    22

    Check my Select Statement in Form

    Good morning,



    I was wondering if someone could take a look at my Select Statement and give me some insight as to how it needs to be changed to perform a specific task. Thank you in advance!

    Statement in Form (QuoteLineItems2):

    SELECT [Repair Directory].[PartNumber], [Repair Directory].[RepairDes] FROM [Repair Directory] WHERE ((([Repair Directory].[PartNumber])=([Forms]![QuoteLineItems2]![combo17])));

    Table is Repair Directory (includes PartNumber, RepairDes)
    Form is QuoteLineItems2 (combo17 ----> which is PartNumber taken from another table named Parts using the statement: "SELECT [Parts].[PartNumber], [Parts].[PartDescription] FROM Parts ORDER BY [PartNumber]; ")

    The Goal:
    There are several "RepairDes" for each "PartNumber". I am attempting to have the available "RepairDes" appear in a dropdown for the "PartNumber" that has been chosen on the "QuoteLineItems2" form.

    Any guidance would be much appreciated!!

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    remove the partNumber from your SELECT portion, you dont need it. Once you remove it, just make a combobox or listbox's rowsource be that query.
    so:
    SELECT RepairDes FROM [Repair Directory] WHERE PartNumber = Forms!QuoteLIneItems2!combo17

    further, I'd recommend renaming combo17 to something relevant so that it's easier to recall. Also, try to not have any spaces or special characters in table names or field names. just bad practice.

  3. #3
    Join Date
    Sep 2010
    Posts
    22
    Thank you so much for the quick response and the tips on spaces and field names.

    When I removed the PartNumber, my combobox returned blank values. When I had PartNumber in the Select Statement it returned data that did not relate to PartNumber. Any other suggestions?

  4. #4
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    throw that SELECT statement into a blank query and see if it returns results correctly. If so, there's no reason why it shouldnt work in the combobox. If not, make sure everything is spelled correctly.

  5. #5
    Join Date
    Sep 2010
    Posts
    22
    Select Statement works perfect in the Query, but not in the Form. I copied and pasted from the Query, so spelling should not be an issue.

    In the Query, I typed in a PartNumber manually. Is there any possibility that since PartNumber is also a SELECT type field, Access doesn't know what to do? Could any predicates or other clauses help? Drawing straws here...

  6. #6
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Are you putting this into Combo17? If so, it wont work. Wherever the ID is stored on the form should be the control you use.

  7. #7
    Join Date
    Sep 2010
    Posts
    22
    No, I believe that would cause a circular reference error. PartNumber is in Combo17 and I am trying to populate Combo19 (RepairDes).

  8. #8
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Ok. Put the query as the rowsource (or controlsource, i forget which one) of combo19 and then in the after_update event of combo 17 put Me.combo19.Requery. That should work.

  9. #9
    Join Date
    Sep 2010
    Posts
    22
    For Combo19, I have the following:
    ControlSource: RepairDescription (field in the table where the data will be stored)
    RowSource: SELECT RepairDes FROM [Repair Directory] WHERE PartNumber=Forms!QuoteLIneItems2!combo17; (my select statement to retrieve the partnumber in the form and tell me what types of RepairDes's are available)

    For Combo17, I have the following Event:
    Me.combo19.Requery

    Error Message: Microsoft Office Access can't fine the object 'Me'

    I must have read your instructions incorrectly, can you tell me where I screwed up? Thank you!

  10. #10
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    love that name!

  11. #11
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Did you put the Requery just in the line or open up the VBA editor in put it in there? It should be in the VBA editor.

  12. #12
    Join Date
    Sep 2010
    Posts
    22
    Thank you Adam!!

  13. #13
    Join Date
    Sep 2010
    Posts
    22
    Hi Shabz,

    I apologize for not responding sooner. Just wanted to let you know that I did the requery using a Macro and it works great. Thank you so much for the guidance and patience!!

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

Similar Threads

  1. Conditional Select Statement
    By shexe in forum Queries
    Replies: 4
    Last Post: 09-22-2010, 09:10 AM
  2. select statement
    By jellybeannn in forum Access
    Replies: 5
    Last Post: 08-13-2010, 05:21 AM
  3. Select statement syntax?
    By ksmith in forum Programming
    Replies: 3
    Last Post: 06-24-2010, 09:21 AM
  4. What is wrong with my SQL Select statement?
    By John2810 in forum Programming
    Replies: 2
    Last Post: 04-01-2010, 10:30 AM
  5. OpenReport Command with Double Check Where Statement
    By Robert M in forum Programming
    Replies: 3
    Last Post: 09-17-2009, 04:01 PM

Tags for this Thread

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