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 / September 2005

Tip: Looking for answers? Try searching our database.

Open Report with criteria in VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alec - 08 Sep 2005 14:36 GMT
Hey guys,
here is the deal. I am opening a report from a form (tab control type of
form) that has a combo box with a list of Airport codes (station).
here is the code:
   Dim stDocName As String
   Dim stLinkCriteria As String
   Dim stValue As String

   stDocName = "rpt_StnRecord"
   stValue = Me![Combo12]
   stLinkCriteria = "[Station]=" & stValue
   DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

As you can see, the report (rpt_StnRecord) is supposed to open using as
Station (field) criteria the value in the Combo12 (located on the tab form).
This works well except that I cannot get the report to open right away. I get
another box popping up asking me to enter the station value (which is already
in combo12).

I dont get it. Any idea?
Thanks guys.
Alec
Eric D - 08 Sep 2005 14:48 GMT
Change the Me![Combo12] to Forms![YourFormName].[Combo12]

I believe that because you are using Me![Combo12] and opening a report, the
report gets the focus and looks for Me![Combo12]... which it can't find.
Bottom line... never use Me![FieldName] when passing variables.

>Hey guys,
>here is the deal. I am opening a report from a form (tab control type of
[quoted text clipped - 18 lines]
>Thanks guys.
>Alec
Alec - 08 Sep 2005 15:09 GMT
I just tried and it does not work. I still a little pop up window where I
have to enter the value.
Any other suggestions?
Thanks for your help.

> Change the Me![Combo12] to Forms![YourFormName].[Combo12]
>
[quoted text clipped - 24 lines]
> >Thanks guys.
> >Alec
 
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.