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 / New Users / November 2006

Tip: Looking for answers? Try searching our database.

Print command button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jane - 03 Nov 2006 17:54 GMT
I created a database that has a command button on it.  The button is to print
a certain ID#.  In stead it prints all the records.   I would like it to ask
which record to print but I can't figure out how to do this.  If someone
could help I would greatly appreciate it.  I have access 2003.  Thanks
Ken Sheridan - 03 Nov 2006 18:23 GMT
I'm assuming it’s a report that's being printed rather than a form.  If you
used the wizard to create the button it will include code in the button's
Click event procedure along these lines:

   Dim stDocName As String

   stDocName = "Elaine"
   DoCmd.OpenReport stDocName, acNormal

Add an unbound text box to your form into which the ID can be entered, and
call it TextID say.
 
Then change the code like so:

   Dim stDocName As String, stCriteria As String

   stDocName = "YourReportName"
   stCriteria = "[ID#] = " & Me.txtID

   DoCmd.OpenReport stDocName, _
       View:=acNormal, _
       WhereCondition:=stCriteria

This assumes that the ID# field is a number data type.  Should it be a text
data type warp the value in quotes likes so:

   stCriteria = "[ID#] = """ & Me.txtID & """"

You could of course put the button on a form bound to the table or query, in
which case it would print the record(s) with current ID number, rather than
entering the ID number in an unbound form.  If you do that you should make
sure the record  is saved before printing so that it reflects any changes
made in the form.  Add the following line before calling the OpenReport
method:

   RunCommand acCmdSaveRecord

Ken Sheridan
Stafford, England

> I created a database that has a command button on it.  The button is to print
> a certain ID#.  In stead it prints all the records.   I would like it to ask
> which record to print but I can't figure out how to do this.  If someone
> could help I would greatly appreciate it.  I have access 2003.  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.