Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2012
    Posts
    4

    Unanswered: CBO event not responding or opening form. Access 2010

    Title: CBO event not responding or opening form. Access 2010
    Desired action : cbo is populated with query but always shows the last record, ID=3. It is desired that a double click event on the CBO will open a sub form with the selected record. Currently it is not working this way.
    Issues:
    1. Value of CBO being passed is not changing, sub form always opens to record 3.
    2. Displayed value in CBO is not changing and stuck on 3, the value being passed and last record in table, bound column is #1, 'id'
    3. 'Me' reference is not working
    4. Openargs argument shows text “ID” being passed rather than a value

    CBO Code---
    Private Sub Combo14_DblClick(Cancel As Integer)
    'Set OpenArgs = 0
    Me.Combo14 = Me.Combo14.Column(0, 1)
    DoCmd.OpenForm "Data Values Input", , , , , , "[ID] = " & Combo14
    End Sub


    Subform code----
    Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(OpenArgs) Then
    Debug.Print "open args from data values input " & OpenArgs
    Me.Filter = OpenArgs
    Me.FilterOn = True
    End If
    End Sub


    coming back to programming after a hiatus and some things seem to have changed, where in A2010 do you set references?

    Any help or comments would be appreciated, will be back on later today.

    Thanks
    Powerhammer

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    CBO Code---
    Private Sub Combo14_DblClick(Cancel As Integer)
    'Set OpenArgs = 0
    Me.Combo14 = Me.Combo14.Column(0, 1)
    DoCmd.OpenForm "Data Values Input", , , , , , "[ID] = " & Combo14
    End Sub
    The purpose of a combobox is to allow the user to enter something into the box and update the information. If your user won't enter information, you don't need a combobox at all. If information is entered, you need to perform some action as a result of the data entry. You use the combobox's On Update event for that, not the On Double Click event.

    Sam

  3. #3
    Join Date
    Aug 2012
    Posts
    4

    List box value

    ok, I've gone back to a list box as follows:

    Private Sub List8_DblClick(Cancel As Integer)

    DoCmd.OpenForm "Data Values Input", acNormal, , whereCondition:="ID =" & ID

    End Sub

    however the list box is not passing the ID value. underlying query for List8 is as follows:
    Public Sub Form_Load()
    With Me.List8
    .RowSource = _
    "SELECT DataValues.ID as ID, DataValues.[Contract Number] as NBR, DataValues.Contractor as KR FROM DataValues ORDER BY DataValues.[ID];"
    .ColumnCount = 3
    .BoundColumn = 1
    .ColumnWidths = ".5 in; .75 in; 3 in"
    End With

    End Sub

    Can someone tell me why the ID value is not showing up for the DoCmd? The intermediate window shows it is blank, not even null. If I set the value as a test in the double click event, all works well. This is a question of passing the value from the list box and its query to to the event.
    Thanks
    Powerhammer

  4. #4
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    The same thing applies to a list box as to a combobox; if there's to be no data entry, you don't need one. Period. Also, like a combobox, if you don't use the On Update condition, you're not accessing the user's input. Period.

    If you want to open a form based on some data, and you're not having the user input the data, then you must figure out how to get it. Since you're obviously bypassing user input, how do you want the DoCmd to get the correct ID number to search for?

    Of course the list box's value is empty. You never gave the user the opportunity to enter anything. The list box, like a combobox, only obtains a value if a USER inputs something.

    In short, what you need to do is as follows:

    Remove the DoCmd statement from the DblClk event. Create a new OnUpdate event and put it in there. You need to tweak the DoCmd a bit also. The correct code is
    Code:
    DoCmd.OpenForm "Data Values Input", acNormal, , "ID = " & Me.List8
    What this does is to allow the user to see his choices, select one, and open the form with that ID info.

    Sam

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Quote Originally Posted by powerhammer1 View Post

    1. Value of CBO being passed is not changing, sub form always opens to record 3.
    2. Displayed value in CBO is not changing and stuck on 3, the value being passed and last record in table, bound column is #1, 'id'

    Code:
    Private Sub Combo14_DblClick(Cancel As Integer)
    'Set OpenArgs = 0
    Me.Combo14 = Me.Combo14.Column(0, 1)
    DoCmd.OpenForm "Data Values Input", , , , , , "[ID] =  " & Combo14
    End Sub
    What is the line in red, above, suppoesed to be doing? If you're using the Combobox to select an ID, why are you trying to set the Combobox Value to the same thing, each time?

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Aug 2012
    Posts
    4
    Sam,

    Made your suggested changes, but----

    The listbox or combobox in my mind is used for selection of a record. Data entry in the sense of providing a value to use later for drill down. Data entry for a record occurs elsewhere. Disagree?

    Opening the form populates the box, user selects the desired record.
    to view it.

    Currently the me.list8 value is not filled, still empty. The me reference doesn't seem to make any difference vs the forms approach. Neither is working.

    Also there is no onupdate event so I've put it in the enter,dblclick and afterupdate events. The only one responding is the double click after the initial entry event.

    So I'm still in the same spot for progress on passing the value as several days ago and looking for additional insight and hair.

    Thanks
    Powerhammer

  7. #7
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Quote Originally Posted by powerhammer1 View Post
    Sam,

    Made your suggested changes, but----

    The listbox or combobox in my mind is used for selection of a record. Data entry in the sense of providing a value to use later for drill down. Data entry for a record occurs elsewhere. Disagree?

    Opening the form populates the box, user selects the desired record.
    to view it.
    You can use a combobox/list box for data entry. It's one of the common data types in table fields. Just open any table in design mode and click on the down arrow of the data type. It's the one called 'Lookup Wizard...'

    Currently the me.list8 value is not filled, still empty. The me reference doesn't seem to make any difference vs the forms approach. Neither is working.
    That's because you still have the DoCmd in other events. See later.

    Also there is no onupdate event so I've put it in the enter,dblclick and afterupdate events. The only one responding is the double click after the initial entry event.
    You are right. There's no OnUpdate event. I was thinking of the AfterUpdate event. Please remove the DoCmd statement from ALL other events and put it solely into the AfterUpdate event. I apologize for the error.

    So I'm still in the same spot for progress on passing the value as several days ago and looking for additional insight and hair.
    When you find the hair, please pass some my way. I've lost too much of mine. HELP! I'm only 63....

    Good luck,

    Sam

Posting Permissions

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