Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Jan 2013
    Posts
    6

    Unanswered: Second Form will not Requery

    Hi, I'm new to this stuff and couldn't find an answer to this question.

    What I'm trying to do is open a second form(not a subform) from my main form which uses the data selected in a combobox on the main form. I can get the second form to open and bring the selection from the combobox over to the second form. Since the second form is based off a different query. I cannot get it to requery for the life of me.

    The second form shows the right selection in the combobox but the data beneath is for the first record of the query associated with that form. When I grab the pull down arrow next to the combobox, it will re-populate with the correct data.

    I want it to automatically repopulate after the form has opened. Here is my code right now. Any help would be appreciated.

    DoCmd.OpenForm "Form2"
    Forms![Form2]![Combo329] = Forms![Form1]![Combo0]
    Forms![Form2]![Combo329].Requery

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Code:
    Forms![Form2]![Combo329] = Forms![Form1]![Combo0]
    Forms![Form2]![Combo329].Requery
    Your first line, above, is assigning the Value of [Combo0] to [Combo329].

    Your second line, above, is doing a Requery of [Combo329], which totally negates the action in the first line!

    You need to Requery your Form2, not [Combo329], based on the Value that was brought over from Form1.

    In point of fact, you probably should simply open Form2 using the Value from Form1 directly; there's no real reason to use the [Combo329] Combobox.

    Linq ;0)>
    Last edited by Missinglinq; 01-11-13 at 09:09.
    Hope this helps!

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

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Jan 2013
    Posts
    6
    How do I requery based on the value from Form1? I thought it was based on the Combo329.

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    What, exactly, is the Value being passed from Form1 to Form2?

    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

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    shouldn't that read
    Forms![Form2]![Combo329].value = Forms![Form1]![Combo0].value
    my reading of the original code is that you are assigning combo to combo329
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Jan 2013
    Posts
    6
    The value I'm trying to pass is a selected name from the combobox on form 1. A text field.

  7. #7
    Join Date
    Jan 2013
    Posts
    6
    I tried healdem's suggestion and it didn't work. When I get the form to open, it pastes the value into the combobox but still shows the details of the first record in the query.

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    ?

    first I've red about a query on this problem

    In that case I'd suggest you copy your db
    strip out any sensitive data
    compact and repair the db (to clear out wasted space) then zip the file and attach here
    I'd rather be riding on the Tiger 800 or the Norton

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

    shouldn't that read

    ...Forms![Form2]![Combo329].value = Forms![Form1]![Combo0].value
    C'mon, healdem, you know that .Value is the Default Property of Comboboxes, and hence doesn't have to be included in code!

    Forms![Form2]![Combo329]

    and

    Forms![Form2]![Combo329].value

    means the same thing!

    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

  10. #10
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    quite possibly
    I get confused when dealign with VB6, .NET VBA and god knows what else
    so confused that I don't like leaving this open to JIT compilers to work out what I want.

    itsafaircopyyerhonner
    I'd rather be riding on the Tiger 800 or the Norton

  11. #11
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I atill haven't got a scooby what the OP is requesting though
    I'd rather be riding on the Tiger 800 or the Norton

  12. #12
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Presumably, the Value being passed to [Combo329] is a also a Field in the Records in Form2. If this is so, you can bypass the Combobox altogether and simply open Form2, to the desired Record, like this:

    In Form1

    Code:
    If Not IsNull(Me.Combo0) Then
      DoCmd.OpenForm "Form2", , , , , , Me.Combo0
    Else
      MsgBox "A selection must be made from Combo0!"
    End If
    End Sub

    In Form2

    Code:
    Private Sub Form_Load()
    
    Dim rst As Recordset
    
    If Not IsNull(Me.OpenArgs) Then
     Set rst = Me.RecordsetClone
     
     rst.FindFirst "[SelectedNameField] = '" & Me.OpenArgs & "'"  
    
      If Not rst.NoMatch Then
          Me.Bookmark = rst.Bookmark
       Else
        Msgbox “No Matching Record was Found!”
       End If
    
    rst.Close
    Set rst = Nothing
    End If
    
    End Sub


    Simply substitute the actual name of the Field, in the RecordSource of Form2, for SelectedNameField, in the code above.

    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

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

    I get confused when dealign with VB6, .NET VBA
    That's completely understandable! VB6, VB.NET and VBA all were sired by QuickBasic 4.5, in turn, and kept most of the same names of Objects, Functions and Commands! And the really confusing thing is that the rules for each, even the functions carried out by each, are sometimes the same and sometimes totally different...even when they have the same names!

    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

  14. #14
    Join Date
    Jan 2013
    Posts
    6
    Hi,

    It took some time to simplify this form to its smallest state.

    Form1 is called "At a Glance" It has a broad definition of the services available. Select a Client from the ComboBox above. I need to pull the name of the Client through to the Form "Services Detail Form2" when I click the button "Detailed Level"

    Form 2 gives a more granular view of the details. Each service has a sub service. Which is why I need the Second form to populate with the selection from Form1.

    All I can get it to do is show the first record on Form 2, but it shows the name of the selection from Form 1.

  15. #15
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Okay, in your 'Client at a Glance Form', use this code in place of your current code:
    Code:
    Private Sub Command179_Click()
    
     If Len(Nz(Me.Combo0, "")) > 0 Then
      
      DoCmd.OpenForm "services detail Form2", , , , , , Me.Combo0
      Forms![services detail Form2]![Combo329] = Forms![Client At A Glance]![Combo0]
     
     Else
      MsgBox "You Must First Select a Client!"
     End If
     
    End Sub

    Then place this code in your secondary Form:
    Code:
    Private Sub Form_Load()
    
    Dim rst As Recordset
    
    If Not IsNull(Me.OpenArgs) Then
     
     Set rst = Me.RecordsetClone
     
     rst.FindFirst "[Client Hierarchy] = '" & Me.OpenArgs & "'"
      If Not rst.NoMatch Then
       Me.Bookmark = rst.Bookmark
      Else
       MsgBox "This Client Does Not Exist!"
      End If
    
    rst.Close
    
    Set rst = Nothing
    
    End If
    
    End Sub

    You should be set, now.

    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

Posting Permissions

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