Question

Here's the grand vision.

I'm building a parts database that will be used for electronics dis-assembly.

when a part is initially removed from the PCB it's reference designator and measured value will be recorded (each part type has a custom entry form, e.g. resistors, capactors, IC's, etc). Later, we will return to each part and add more detail.

At this point I'm able to select existing parts from a combo box, use the FindFirst function to locate it's record in the main table, extract the corresponding part type information, and open the appropriate data entry form.

What I can't figure out is how to then display that record in the newly opened form. The typical Me.Bookmark = rs.Bookmark strategy doesn't work since I'm opening a new form

Private Sub cmdEditPart_Click()
Dim rs As Recordset
Dim qdf As QueryDef
Dim prm As Parameter
Dim partType As String
Set qdf = CurrentDb.QueryDefs("Parts_SingleBoard")
qdf.Parameters(0) = Forms![Start Page (Boards)]![ComboPartNumber]

'Lookup record
    If Not IsNull(Me.cmbRefDes) Then
        'Save before move.
        If Me.Dirty Then
            Me.Dirty = False
        End If
        'Search in the clone set.
        Set rs = qdf.OpenRecordset.Clone
        rs.FindFirst "[Reference Designator] = '" & Me.cmbRefDes & "'"
        If rs.NoMatch Then
            MsgBox "Part not found"
        Else
            'Display the found record in the appropriate form.
            partType = rs.Fields("Part Type")
            DoCmd.OpenForm (partType)
            'Some sort of bookmark wizardy ****THIS IS WHAT I NEED HELP WITH *****
        End If
        Set rs = Nothing
    End If
End Sub

4 step recap:

View list of existing parts -> select part -> dynamically open correct data entry form -> populate form with the record I want to edit

Was it helpful?

Solution

Use the filter mechanism built into the DoCmd.OpenForm method, something like this:

DoCmd.OpenForm (partType), , , "[Reference Designator] = '" & Me.cmbRefDes & "'"

I'm not sure if I have enough commas before my filter statement. You might need four commas.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top