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 / Modules / DAO / VBA / May 2008

Tip: Looking for answers? Try searching our database.

Help with vba

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
C Tate - 20 May 2008 15:00 GMT
I am trying to create a listbox to search for records. The example I am using
is from www.databasedev.co.uk/list_box_searching.html.

I am using this code but it just will not work.

Private Sub ShowRecord_Click()
'Find a selected record, then close the search dialog box

   DoCmd.OpenForm "frmSite", , , _
       "[tblSite.siteID]=" & "'" & Me.FirstSearch.Column(0) & "'"
   
'Close the dialog box
   DoCmd.Close acForm, "frmSearch"
End Sub

I note that their example is searching on a textfield whereas mine is
searching on an autonumber field. I cannot possibly imagine what I am doing
wrong. It seems to highlight the me.firstsearch.column(0) bit. I have named
the listbox firstsearch. Can access automatically work out column numbers? If
not, how do I name them? Any advice would be most helpful. Thanks.
Dennis - 20 May 2008 15:46 GMT
Text fields require apostrophies around the text item whereas numbers do not,
so your code should look like this

DoCmd.OpenForm "frmSite", , , _
        "[tblSite.siteID]=" & Me.FirstSearch.Column(0)

> I am trying to create a listbox to search for records. The example I am using
> is from www.databasedev.co.uk/list_box_searching.html.
[quoted text clipped - 16 lines]
> the listbox firstsearch. Can access automatically work out column numbers? If
> not, how do I name them? Any advice would be most helpful. Thanks.
C Tate - 20 May 2008 15:59 GMT
Brilliant! Thanks so much

> Text fields require apostrophies around the text item whereas numbers do not,
> so your code should look like this
[quoted text clipped - 22 lines]
> > the listbox firstsearch. Can access automatically work out column numbers? If
> > not, how do I name them? Any advice would be most helpful. Thanks.
 
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.