Re: opening new form in same id



well, what do you mean by "showing the same candidate"?

your form Candidates is bound to a table Candidates, i assume, or to a query
based on tblCandidates. are the "left" details stored in another table? or
in the same table? if another table, is that table properly related to the
Candidate table, in the Relationships window?

and when you open the "left" window, are you expecting to see existing
records related to the candidate record in the Candidate form? or are you
only wanting to add a *new* record in the "left" form? if the latter, then
applying a WHERE clause to the "left" form's RecordSource won't get you
anywhere. what you need is to have the CandidateID automatically inserted
into the new record when you begin typing it. instead of using the WHERE
clause argument, try using the OpenForm's OpenArgs argument, as

DoCmd.OpenForm "frmLeftDetails", , , , , , Me!CandidateID

then you can add code to the "left" form's BeforeInsert event to add the
value to each new record, as

Me!CandidateID = Me.OpenArgs

whether or not you "see" the candidate depends on whether or not the
CandidateID field in the "left" form is bound to a control, and since i
assume you'd want to see a name not an ID, that control would have to be a
combobox control.

hth


"JB" <somehow@somewhere> wrote in message
news:OjQD4xBwJHA.5584@xxxxxxxxxxxxxxxxxxxxxxx
Hi
This is what I've got, but the CandidateId field isn't showing anyone
.........
Private Sub cmdLeft_Click()
On Error GoTo Err_cmdLeft_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmLeftDetails"

stLinkCriteria = "[CandidateID]=" & Me![CandidateID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdLeft_Click:
Exit Sub

Err_cmdLeft_Click:
MsgBox Err.Description
Resume Exit_cmdLeft_Click

End Sub
................

thanks Jen



"Philip Herlihy" <bounceback@xxxxxxx> wrote in message
news:uxnvcXBwJHA.4364@xxxxxxxxxxxxxxxxxxxxxxx
JB wrote:
Hello.
I have a form 'Candidates' that has candidate details which you can add
new candidates or view existing.
There is a button 'Left' that opens another form where you put
details
if the Candidate has left, date and reason.

I would like for that form to open showing the same candidate that is
open on the main form.

Thank you
Jen

You'd want a command button with the onclick event calling a procedure
using DoCmd.OpenForm

Have a look at that in Help - you would include a "Where" condition so
that the candidate in the opened form must be equal to the candidate in
the form already open.

Phil, London



.