Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2011
    Posts
    3

    Unanswered: Query, Selected Record

    I created an unbound text box that I named SelectedID. I want users to be able to type a specific ID that will pull up a form with the database information on an easier to read form. I entered this into the SQL

    SELECT Requests.ID, Requests.[Request Date], Requests.[Last Name], Requests.[First Name], Requests.[Middle Name], Requests.[Maiden/Other Name], Requests.SSN, Requests.DOB, Requests.[Pick Up: Name], Requests.[Pick Up: Relationship], Requests.[Send to], Requests.[Send to Attention], Requests.[Address 1], Requests.[Address 2], Requests.[Address 3], Requests.City, Requests.State, Requests.Zip, Requests.[Fax To Number], Requests.[Email to Email Address], Requests.[Sent Date], Requests.[Sent Time], Requests.Notes
    FROM Requests
    WHERE (((Requests.ID)=[Forms]![Main Menu]![SelectedID]));

    I have gotten it to work in a different database, but for some reason on this one, when I enter any ID # it only brings up the very first record from the table. Any ideas why?

    Thank you in advance
    Kelly

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    What's in the WHERE clause when the code is run? I would place a breakpoint after the SQL sentence is composed and see how [Forms]![Main Menu]![SelectedID] is interpreted.

    And also, you just provided the query but no code. What do you do with that query and how do you open the form?
    Have a nice day!

  3. #3
    Join Date
    Oct 2011
    Posts
    3
    Quote Originally Posted by Sinndho View Post
    What's in the WHERE clause when the code is run? I would place a breakpoint after the SQL sentence is composed and see how [Forms]![Main Menu]![SelectedID] is interpreted.

    And also, you just provided the query but no code. What do you do with that query and how do you open the form?
    Sorry I am new to this kind of thing This is the code

    Option Compare Database

    Private Sub CumulID_Q_Search_Click()
    DoCmd.OpenForm "Cumulative Returned Receipt"
    End Sub

    Private Sub Command98_Click()
    DoCmd.OpenTable "Cumulative File Transfer Receipt"
    End Sub


    Is this more helpful ?

  4. #4
    Join Date
    Oct 2011
    Posts
    3
    Maybe this can help some too
    Attached Files Attached Files

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by kkromo View Post
    Is this more helpful ?
    Not a lot actually. Is the RecordSource of the form "Cumulative Returned Receipt" based on the query "CumulID SelectedID Query"?

    In such a case, you don't usually put a WHERE clause based on the contents of a control from a form in the query (mainly because the query fails if the form is closed). The query selects all records (i.e. no WHERE clause based on Requests.ID) and you open the second form (here "Cumulative Returned Receipt") with a criteria:
    Code:
    Docmd.OpenForm "Cumulative Returned Receipt", , , "Requests.ID=" & Me.SelectedID.Value
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •