OpenForm trouble

C

Chip

Hey everyone,

I have a form that has a Combo box. The bound value of the combo box
is an ID field, but the value displayed is a text entry. What i want
to have happen is when teh user Dbl clicks on the combo box, a form
opens up that allows the user to edit information about that
appointment.

The combo box is a test even. The title fo the test even is just a
free form text entry. The combo box is based on a query. The query
returns multiple items about that including, date, location and
representative. Many of these details are developed as our business
progresses. For example, we may know when and where an event will
take place, but not what employee will oversee it. So when we want to
add data to that event, the user cand dbl click and the form opens
where he can edit that information. In essence, I'm doing a
DoCmd.OpenForm with a Where clause. Here is my line of code...

Private Sub Practical_Exam_DblClick(Cancel As Integer)
DoCmd.OpenForm(Form!frmSExam, , , "[ID]='" & Me![Practical Exam] &
"', , ,)
End Sub

Now, the control where the user dbl clicks is called [Practical
Exam]. The bound column for this control is [ID] and ID is a
autonumber that is assigned to each testing event. frmSExam is that
form where information about the testing event is changed/add/etc.

I dont need anything funky, just open the form and move to the record
for that particular event. If you asked me to point directly to where
the number would be stored, I'd say you need to go to Me![Practical
Exam].Column(1). I tried that but it doesnt work either.

I even tried to pass the ID to a field, that I was going to hide. I
tried to program the dblclick event to go to that hidden text box,
pull the number and use that. It wasnt very graceful, and I'm sure it
isnt good programming form. But it didnt eitehr, so.. I'm stuck..

chip
 
J

Jeanette Cunningham

Hi Chip,
what is the ID field for the form frmSExam you are trying to open?

If you can choose the primary key field for frmSExam in the combo
that you double click, it is easy to open frmSExam at exactly that record.

See if the query for the combo has that primary key field from frmSExam
in its first column that is also the bound column of the combo.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
B

Beetle

Looks like your syntax is just a bit off for the OpenForm
method. You just refer to the form name directly (without
the additional reference to the Forms collection), and if the
bound column of your combo box is an autonumber field then
you don't need the single quotes around it. Example;

DoCmd.OpenForm frmSExam, , , "[ID]=" & Me![Practical Exam]
 

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