Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Click on list Item and open a Detail form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sara - 31 Jul 2007 16:48 GMT
Hi Everebody,

I need help withe the following: I have a form that has a listbox that gets
its data through a query, the list box only show two colums: Company and
ProcessDate, also the query retrieves more fields but I set the width of the
columns to zero.
I also have a command button "CmdViewDetail" that on_click should open a new
form that will contain the rest of the information for the record I selected
on the list box.
How should I do this? I'm not very experienced with vba, could somebody help
me?
Stefan Hoffmann - 31 Jul 2007 17:03 GMT
hi Sara,

> I also have a command button "CmdViewDetail" that on_click should open a new
> form that will contain the rest of the information for the record I selected
> on the list box.
> How should I do this? I'm not very experienced with vba, could somebody help
> me?
Use the click event of the listbox:

Private Sub lbCompanies_Click()

  Dim Condition As String

  Condition = "ID=" & lbCompanies.Column(1)
  DoCmd.OpenForm "yourForm",,, Condition

End Sub

Where Condition is a WHERE clause without the where. The index in the
.Column() function points to the column holding the primary key.

mfG
--> stefan <--
Maurice - 31 Jul 2007 17:14 GMT
Sara,

Make sure the listbox has the keycolumn defined for the recordinfo you want
to show on the form. Usually this is the first column which columnwidth is
then set to 0 (zero).

Now put the following code behind the onclick  from the "CmdViewDetail"
button:

docmd.openform "yourformname here",,"keyfield= " & me.listbox

Change the yourformname to the name of the form you want to open.
Change the keyfield to the name of the keyfield from the recordsource for
that form
Change the name of the listbox in me.listbox to the name of your listbox.

If the keyfield is a string you should type the following:
docmd.openform "yourformname here",,"keyfield= '" & me.listbox & "'"

That is single quote and a double qoute after the = sign and a double quote,
single quote and a double quote after the last &

hth

Signature

Maurice Ausum

> Hi Everebody,
>
[quoted text clipped - 7 lines]
> How should I do this? I'm not very experienced with vba, could somebody help
> me?
Sara - 31 Jul 2007 18:20 GMT
Thanks a lot Maurice and Stefan!!!

> Sara,
>
[quoted text clipped - 31 lines]
> > How should I do this? I'm not very experienced with vba, could somebody help
> > me?
Dale Fye - 31 Jul 2007 19:02 GMT
Sara,

You might also want to consider disabling the command button unless an item
is selected in the list.  You can do this by disabling the command button in
design view, then add some code in the Click event of the listbox to enable
the button.

Dale

Signature

Email address is not valid.
Please reply to newsgroup only.

> Thanks a lot Maurice and Stefan!!!
>
[quoted text clipped - 33 lines]
> > > How should I do this? I'm not very experienced with vba, could somebody help
> > > me?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.