On Cick Code needed!

B

Bob

I have created a dropdown combo list box (cbOwnerMain) now I want it to open
the owners record form when I click on his name, the form name that the
owners appear on is (FrmOwnerInfo) and the Query is (qryOwnerInfo), I
suppose something on click event!




Thanks in advance.........Bob Vance
 
L

Larry Linson

If you code at all, check Help on the DoCmd.OpenForm statement and that will
likely be all you need.

If you do not, post back with the name of the owner's name key Field in the
Query for the Form you want to open and someone can likely give you the code
you need to use in the AfterUpdate event of cbOwnerMain.

Larry Linson
Microsoft Access MVP
 
B

Bob

This is Sql code in qryOwnerInfo:

SELECT tblOwnerInfo_OwnerID,
IIf(IsNull(tblOwnerInfo_OwnerLastName),'',tblOwnerInfo_OwnerLastName & ' ')
& IIf(IsNull(tblOwnerInfo_OwnerFirstName),'',tblOwnerInfo_OwnerFirstName & '
') & IIf(IsNull(tblOwnerInfo_OwnerTitle),'',tblOwnerInfo_OwnerTitle) AS Name
FROM tblOwnerInfo
WHERE (((tblOwnerInfo.Status)='Active'))
ORDER BY
IIf(IsNull(tblOwnerInfo_OwnerLastName),'',tblOwnerInfo_OwnerLastName & ' ')
& IIf(IsNull(tblOwnerInfo_OwnerFirstName),'',tblOwnerInfo_OwnerFirstName & '
') & IIf(IsNull(tblOwnerInfo_OwnerTitle),'',tblOwnerInfo_OwnerTitle);
Thanks Bob
 
B

Bob

Got it:
Private Sub cbOwner_AfterUpdate()
DoCmd.OpenForm "frmOwnerInfo", , , "OwnerID=" & val(cbOwner.value)
End Sub
Thanks for your help...Bob
 
A

Arvin Meyer [MVP]

Bob said:
Got it:
Private Sub cbOwner_AfterUpdate()
DoCmd.OpenForm "frmOwnerInfo", , , "OwnerID=" & val(cbOwner.value)
End Sub
Thanks for your help...Bob

This line should work just as well:

DoCmd.OpenForm "frmOwnerInfo", , , "OwnerID=" & cbOwner

The Val() function returns the numbers from a string and there shouldn't be
a string in most ID fields. The .value property is the default property of
data controls, so it's unnecessary to use it.
--
Arvin Meyer, MCP, MVP
Free MS-Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 

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