On Cick Code needed!

  • Thread starter Thread starter Bob
  • Start date Start date
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
 
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
 
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
 
Got it:
Private Sub cbOwner_AfterUpdate()
DoCmd.OpenForm "frmOwnerInfo", , , "OwnerID=" & val(cbOwner.value)
End Sub
Thanks for your help...Bob
 
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
 
Back
Top