Results 1 to 6 of 6
  1. #1
    AJ0424 is offline Novice
    Windows XP Access 97
    Join Date
    Jul 2009
    Posts
    2

    Newbie Question: User Entered Field as Query Parameter

    Hi,
    I am *really* new at this - I am trying to use built in functionality because I don't have any code experience so I hope this is clear.

    What I am trying to do is create a form that lets a User enter a product number and have the description returned.

    The problem - I can do this through a query using the criteria (["Enter Product Number"] but that generates a popup. What I am having a hard time doing is using a form to do the same thing but to display the info where I want it to display without the popup.

    What I want:
    Two boxes in the form
    - Box 1 lets them enter a product number
    - Box 2 displays the description

    Simple example of what I have:

    I have:
    Table with 2 fields


    Product Number: Text field (char and numbers), primary key
    Description: Text field

    Query:
    Returns two fields from table with a criteria setting requiring that the Product number: ["Enter Product Number"]


    I hope I am just missing something simple because this doesn't seem like it should be complicated. If anyone can point me in the right direction, I would appreciate it.

    Thanks,
    AJ

    EDITED to Add:
    I found the solution by using the expression builder in the query design. For other newbies, the tutorial I used was:
    http://fisher.osu.edu/~muhanna_1/837/MSAccess/tutorials/mainTOC.pdf
    Last edited by AJ0424; 07-29-2009 at 11:42 AM. Reason: Solution found

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I love it when posters are able to solve their own issues. Thanks for sharing.

  3. #3
    tracamonali is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    4
    Quote Originally Posted by AJ0424 View Post
    Hi,
    I am *really* new at this - I am trying to use built in functionality because I don't have any code experience so I hope this is clear.

    What I am trying to do is create a form that lets a User enter a product number and have the description returned.

    The problem - I can do this through a query using the criteria (["Enter Product Number"] but that generates a popup. What I am having a hard time doing is using a form to do the same thing but to display the info where I want it to display without the popup.

    What I want:
    Two boxes in the form
    - Box 1 lets them enter a product number
    - Box 2 displays the description

    Simple example of what I have:

    I have:
    Table with 2 fields
    Product Number: Text field (char and numbers), primary key
    Description: Text field

    Query:
    Returns two fields from table with a criteria setting requiring that the Product number: ["Enter Product Number"]


    I hope I am just missing something simple because this doesn't seem like it should be complicated. If anyone can point me in the right direction, I would appreciate it.

    Thanks,
    AJ

    EDITED to Add:
    I found the solution by using the expression builder in the query design. For other newbies, the tutorial I used was:
    http://fisher.osu.edu/~muhanna_1/837/MSAccess/tutorials/mainTOC.pdf
    AJ, I have to do the same thing as you had to do. However, the tutorial only opens the Index. Its doesn't open the tutorial document. Here is what I need to do:
    I wish to open an Access report which should read a value from the vb form. The access report should pick up the Hospital# from a textbox and only one record should be opened. Here is my code:

    Private Sub cmdCallLog_Click()
    Dim strWhere As String
    strWhere = "'" & txtHospID.Text & "'"


    Set mAcc = New Access.Application
    mAcc.OpenCurrentDatabase "............mdb"

    mAcc.DoCmd.OpenReport "CTX_HDCALLS_rpt", acViewPreview, , strWhere
    mAcc.Visible = True
    End Sub

    My problem is a popup window opens and request for Hospital# when I set up the criteria in the access report. ["Enter hospital Number"]. I do not wish this to happen. The report should be able to read Hospital# from the variable strwhere. Where am I going wrong? Any help appreciated.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The WhereClause argument of the OpenReport command applies a filter to the RecordSource of the report. It needs to be a complete Where clause without the word WHERE.
    If it is a numeric value then:
    strWhere = "[YourFieldName] = " & Me.txtHospID
    If it is a string value then:
    strWhere = "[YourFieldName] = '" & Me.txtHospID & "'"
    ...replacing YourFieldName with the real name of course.


  5. #5
    tracamonali is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    4
    Quote Originally Posted by RuralGuy View Post
    The WhereClause argument of the OpenReport command applies a filter to the RecordSource of the report. It needs to be a complete Where clause without the word WHERE.
    If it is a numeric value then:
    strWhere = "[YourFieldName] = " & Me.txtHospID
    If it is a string value then:
    strWhere = "[YourFieldName] = '" & Me.txtHospID & "'"
    ...replacing YourFieldName with the real name of course.

    RuralGuy you are my hero. Thanks it worked.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Just glad we could help. Have fun.

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

Similar Threads

  1. User level security question
    By genesis in forum Security
    Replies: 1
    Last Post: 07-08-2009, 10:10 AM
  2. Newbie question
    By The_Dude in forum Programming
    Replies: 2
    Last Post: 12-23-2007, 07:11 PM
  3. Newbie question
    By benplace in forum Queries
    Replies: 1
    Last Post: 12-13-2005, 06:40 PM
  4. Add combo box to parameter query
    By louisa14 in forum Queries
    Replies: 1
    Last Post: 12-10-2005, 08:38 AM
  5. Newbie filter question
    By benplace in forum Access
    Replies: 1
    Last Post: 12-03-2005, 08:31 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