Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting a Field by Double Click Opens a Form???

Status
Not open for further replies.

PureCoffee

Technical User
Apr 3, 2001
19
US
I have a dbase with Contacts and Companies. Under Contacts there is a field which lists the company the contact works with. I would like to be able to "Double-Click" on the name of that Company and automatically have that Company's Form be opened. Can this be done with some simple procedures? Can anyone help me? Do you follow?
Thank you.
 
Here's a function I use in one of my databases to do just that, you place this function in your form module and then run the function in the double-click events of the fields you want it to work in:

Function ViewPartForm()
'Open frmParts, go to selected PartNo
If IsNull(cboPartNo) = False Then
DoCmd.OpenForm "frmParts", acNormal, , "[PartNo]='" _
& cboPartNo & "'", acFormEdit, , "EditModal"
Else
MsgBox "You must double-click on a line with a part!"
End If
End Function


Joe Miller
joe.miller@flotech.net
 
I am too new to understand what you are saying about "placing this function in your Form Module" and then "Run the function" in the Double Click events of the fields"

Cant I go to the Form "Contacts" open up "Design View" and then select "Companies" field and then do an event procedure like you stated?
Thanks - Steve
 
DoCmd.OpenForm "Companies", acNormal, , "[CompanyID]= FormCompanyID, acFormEdit

Yes, put this in the double-click event of the company field in your contacts form. I assume the following, change to match your situation:

Companies = the name of the form you're opening with the company showing

CompanyID = the name of the field containing the company's UNIQUE ID

FormCompanyID = the name of the textbox on the Contacts form holding the CompanyID

HTH

Joe Miller
joe.miller@flotech.net
 
Joe,
I think I am almost there... Here is what I have and it opens the form alright, just not the specific record or "Company" in the box.

Here is what I have so far and thanks for your help and patience..
Private Sub CompanyID_DblClick(Cancel As Integer)
DoCmd.OpenForm "Companies", acNormal, "[CompanyID]=CompanyID,acFormEdit"
End Sub
 
DoCmd.OpenForm "Companies", acNormal, "[CompanyID] = " & CompanyID, acFormEdit

Try this Joe Miller
joe.miller@flotech.net
 
Sorry Joe, There must be something I am doing wrong. It still opens up the "First" company I have listed in the dbase. Hmm. Any other ideas or do you think I just have something wrong in the way the dbase is setup?

SF
 
It is most likely because your db is not finding the appropriate companyid. Can you send me a copy of the db so I can take a look?

Joe Miller
joe.miller@flotech.net
 
Thanks Joe. It is on its way. Far from being finished and I am a fairly new Access User. I am trying hard to learn all I can.

Steve
 
DoCmd.OpenForm "Companies", acNormal, "[CompanyID] = " & CompanyID, acFormEdit

Copy/Paste that OVER the line you currently have in the double click. Notice that it's the SAME as my previous answer. The problem is with the quotation marks you have in there, notice how mine are different than what you have in the db.

Joe Miller
joe.miller@flotech.net
 
Joe,
Thanks but I guess I didn't explain myself very well. What I wanted to do was open the Record or in this case, the Company "Selected" as opposed to ALL company records or the Companies Form. Seems I must do some more "code" or something. As an example looking at the db I sent. Got to contact record #1 (Glen B) He works for TCW. SO I would want to Double-Click on TCW.. and have Access pull up TCW under Companies. Then I will be able to navigate further from there using the links I will have to the companies form. Follow? Thanks for all your help! It is much appreciated. Steve
 
I gotcha now I think! Try this line:

DoCmd.OpenForm "Companies", acNormal, , "[CompanyID] = " & CompanyID, acFormEdit

Only difference is the extra comma in red.

HTH
Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top