Results 1 to 2 of 2
  1. #1
    mhh12 is offline Novice
    Windows XP Access 2010 (version 14.0)
    Join Date
    Jul 2010
    Posts
    3

    Smile doesn't relate

    This is code written in Access 2010.

    This code is in Microsoft Access Class Objects and the object name is Form_frmMETRIC.
    What am I trying to do? I want to filter a file called METRIC by selecting an NID value with a combobox called combo5. The NID value is the primary key in a table called KUseSet. What I see in the combobox is another field which is written in English and has meaning. Combo5 uses the primary key of kUseSet and displays another field which makes sense to the user. After I make the selection, I click the command5 button and should get a filtered list of METRIC. But I don't.



    frmMETRIC has a combobox called Combo3. It does not have a Control Source. It has a row Source which reads
    SELECT [KUseSet].[NID], [KUseSet].[UseSet] FROM KUseSet ORDER BY [UseSet];

    Private Sub Command5_Click()
    On Error GoTo Err_Command5_Click
    ' The following statement brings up METRIC with a count of 1 record ready to be a new record.
    ' I want a filtered list of METRIC; I don't want to input new records to METRIC.

    DoCmd.OpenForm "sfrmMETRIC", acNormal, , "NID =" & Me.Combo3.Value

    ' The following statement causes a form "enter Parameter Value" to appear. I, of course, don't want to give another value. I already selected a value in combo5 and want that value to be used.
    ' DoCmd.OpenForm "sfrmMETRIC", acNormal, , "sfrmMETRIC.NID =" & Me.Combo3.Value

    Exit_Command5_Click:
    Exit Sub
    Err_Command5_Click:
    MsgBox Err.Description
    Resume Exit_Command5_Click
    End Sub

    sfrmMETRIC has a table called METRIC. METRIC has a column called NID.
    When I select a useset in the combobox, the combobox value is the primary keyin the table KUseSet. Then when I click on the command button I get a window up called "enter Parameter Value." I,of course, don't want this window appearing which wants me to write the code which I have already given the program by selecting a value in combo3. Look at the code above starting with DoCmd.OpenForm......
    I just want to select an item in the combobox, click on the command button and get a filtered list of METRIC based on my selection in the combobox.

    Obviously,there is something simple I don't understand.

    How do I do it? Many thanks.
    VBA

  2. #2
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    The reason you get the message "enter Parameter Value" is due to criteria or a field in the recordsource of the form you're opening which it can't parse or find (or possibly in conditional formatting of some field on the form.)

    You could also try:

    DoCmd.OpenForm "sfrmMETRIC", acNormal, , "[NID] = " & Forms!MyMainFormName!Combo3 & ""

    but check the recordsource query of the sfrmMETRIC. If you are opening the form by supplying the "where" parameter, you might have other criteria the in recordsource query of the form which is causing the prompt (or an expression or field name that is incorrect in the query.)

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

Similar Threads

  1. Replies: 1
    Last Post: 07-25-2009, 05:06 PM
  2. Replies: 0
    Last Post: 02-24-2009, 12:37 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