Solved

Combo Box on subform not updating for certain records unless selected twice.

Posted on 2015-01-06
3
259 Views
Last Modified: 2015-01-07
Small DB example attached.

Combo box on subform updates records in conjuction  records in main form "frmInvoice" except for the  last record in combo box "222211111242"
If record "222211111242" is chosen for a second time it updates to the correct record.

Tried Me.Combo15.Requery in various places but not working.

Private Sub Combo15_AfterUpdate()
 
    Me.RecordsetClone.FindFirst "[ShipmentID] = " & Me![Combo15]
    If Not Me.RecordsetClone.NoMatch Then
        Me.Bookmark = Me.RecordsetClone.Bookmark
        Else
        Me.Parent.RecordsetClone.FindFirst "[InvoiceNumber] = " & Me.Combo15.Column(1)
            If Not Me.Parent.RecordsetClone.NoMatch Then
                Me.Parent.Bookmark = Me.Parent.RecordsetClone.Bookmark
                Else
                MsgBox "Record Not found!"
            End If
    End If

End Sub
Invoice-Rev1.zip
0
Comment
Question by:ExpressMan1
3 Comments
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 250 total points
ID: 40535094
It was not the only selection.
First find the invoice, then the shipment.
Here is how:
Private Sub Combo15_AfterUpdate()
 
    Dim rst         As DAO.Recordset
    Dim InvoiceID   As Long
    Dim ShipmentID  As Long
    
    InvoiceID = Val(Me!Combo15.Column(1))
    ShipmentID = Val(Me!Combo15.Value)
    
    If Me.Parent.InvoiceNumber.Value <> InvoiceID Then
        Set rst = Me.Parent.RecordsetClone
        rst.FindFirst "[InvoiceNumber] = " & InvoiceID & ""
        If Not rst.NoMatch Then
            ' This will requery this subform.
            Me.Parent.Bookmark = rst.Bookmark
        End If
    End If
    
    If Me!InvoiceNumber.Value = Me.Parent.InvoiceNumber.Value Then
        Set rst = Me.RecordsetClone
        rst.FindFirst "[ShipmentID] = " & ShipmentID & ""
        If Not rst.NoMatch Then
            Me.Bookmark = rst.Bookmark
        End If
    End If
    
    If Me!ShipmentID.Value <> ShipmentID Then
        MsgBox "Record Not found!"
    End If
    
    Set rst = Nothing

End Sub

Open in new window

/gustav
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 250 total points
ID: 40535492
here test this
Invoice-Rev2.zip
0
 

Author Closing Comment

by:ExpressMan1
ID: 40535750
Both work great. Thank You Rey and Gustav.

Thanks again to Rey as it was his original code I was using. Interesting how this unusual problem can be solved two totally different ways.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now