Open Form from Combo

D

danka

Hello:

I have a form called frmAddCommittment with a cmd buttom that opens a form
called frmSelector. frmSelector form contains a combo cboCommitSelect. Combo
works ok. When users selects RefNumber from the combo list I would like to
open back AddCommittment form (all records not filtered) and find RefNumber
selected from the combo. I tried to use criteria and find first, but I am
not sure how to reference records from the first form (based on query from
table Committments). frmSelector does not know about records and does not
have record source.

It must be a simle way to accomplish this.

Here is what I tried (I cannot get refnumber)

First I open frmAddCommittments and open frmSelector (i pass form name)
This is called from frmSelector, cboCommitSelect comboon click event.

Private Sub cboCommitSelect_Click()

Dim myform As Form, Myset As Recordset
Dim criteria As String

'On Error GoTo OkNumerr

'first set reference variables

Set myform = Forms(Me.OpenArgs) 'calling form message (name)
Set Myset = myform.RecordsetClone 'clone to search (problem here)

If myform.Dirty Then 'check if needs updating
myform.SetFocus 'transfer focus (Me cannot be modal!)
myform.Refresh 'refresh records (could also requery)
End If

criteria = "[RefNumber]= " & Me!cboCommitSelect.Column(0)

Myset.FindFirst criteria

If Not Myset.NoMatch Then
myform.Bookmark = Myset.Bookmark
Else
Beep
MsgBox "Report not found!", 64

Forms!frmAddCommittment![RefNumber].SetFocus
Exit Sub
End If

DoEvents
DoCmd.Close A_FORM, Me.FormName


End Sub

Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top