Dbl Click Code - open a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need some help with this. I'm a novice and have no skills in writing event procedures.

I have a combo box to make selections. I'd like to double click the selection to open a form and its record.

Here are the combo box details:

cbSupplierIDs
-ControlSource: tblSupplierIDs.txtSupplierID
-RowSource: SELECT tblSupplierIDs.txtSupplierID, tblSupplierIDs.txtName, tblSupplierNames.Type FROM tblSupplierNames INNER JOIN tblSupplierIDs ON tblSupplierNames.txtName=tblSupplierIDs.txtName WHERE (((tblSupplierNames.Type)="PK")) ORDER BY tblSupplierIDs.txtName;

The form to open is:
frmPKSuppliers

The form needs to open to the record that was selected in the combo box.

I hope this makes sense - I appreciate your help! THANKS!
 
John,
there is a wizard that will create a combobox that does what you want. When
you place the combo on the form Select the choice "Find a record on my form
based on the value I selected in my combo box."

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


JohnLute said:
I need some help with this. I'm a novice and have no skills in writing event procedures.

I have a combo box to make selections. I'd like to double click the
selection to open a form and its record.
Here are the combo box details:

cbSupplierIDs
-ControlSource: tblSupplierIDs.txtSupplierID
-RowSource: SELECT tblSupplierIDs.txtSupplierID, tblSupplierIDs.txtName,
tblSupplierNames.Type FROM tblSupplierNames INNER JOIN tblSupplierIDs ON
tblSupplierNames.txtName=tblSupplierIDs.txtName WHERE
(((tblSupplierNames.Type)="PK")) ORDER BY tblSupplierIDs.txtName;
 
Lynn Trapp said:
John,
there is a wizard that will create a combobox that does what you
want. When you place the combo on the form Select the choice "Find a
record on my form based on the value I selected in my combo box."



selection to open a form and its record.
tblSupplierNames.Type FROM tblSupplierNames INNER JOIN tblSupplierIDs
ON tblSupplierNames.txtName=tblSupplierIDs.txtName WHERE
(((tblSupplierNames.Type)="PK")) ORDER BY tblSupplierIDs.txtName;

Lynn, I read this as meaning that John wants to open a *different* form
from the one containing the combo box. If that's right, the wizard
selection you suggested isn't what he wants. What he'll need is an
event procedure something like this:

'---- start of example code ----
Private Sub cbSupplierIDs_DblClick(Cancel As Integer)

' If no supplier has been selected, open the form
' to add a record.
If IsNull(Me.cbSupplierIDs) Then
DoCmd.OpenForm "frmPKSuppliers", DataMode:=acFormAdd
Else
' Open the form to the selected record.
DoCmd.OpenForm "frmPKSuppliers", _
WhereCondition:="txtSupplierID='" & Me.cbSupplierIDs & "'"
End If

End Sub
'---- end of example code ----

That assumes that txtSupplierID is a text field, and that it won't
contain the single-quote character (').
 
Thanks - even though that's not exactly what I was looking for, I didn't realize there was a wizard to do this! There's SO MUCH to Access - I don't know how you MVP's do it!
 
Thanks, Dirk! This is it!

Perhaps a little off-topic - I was curious: what's your favorite salad dressing?
 
JohnLute said:
Perhaps a little off-topic - I was curious: what's your favorite
salad dressing?

LOL - that *is* rather off-topic! Do I dare let that private
information out into the Internet community? Are you sure you wouldn't
rather discover my quest and my favorite color?

I tend to favor what the restaurants call "creamy Italian". At home, I
mix oil, balsamic vinegar, and Dijon mustard. Try it some time.
 
Where the heck did *that* question come from?! I sat here blinking and had
to re-read it three times, *and* check back through the thread...

Is there some other thread that might give the question some context?

Fred...
 
Fred Boer said:
Where the heck did *that* question come from?! I sat here blinking
and had to re-read it three times, *and* check back through the
thread...

Is there some other thread that might give the question some context?

LOL! John and I have had some private communications, and I suspect
that his question may have something to do with his threat to send me "a
token of appreciation". I'm just guessing, of course.
 
Back
Top