Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Using Docmd.PrintOut In Access Form


I have an Access form that is bound to a table and then all the text and combo boxes are bound to the form recordsource. I want to include a logo when i do a docmd.printout acprintall, , , but it won't print the image that contains the logo. it prints everything else...why?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Form Doesn't Open Any More {Access - DoCmd.OpenForm}
Hello! Did some of you met the runtime error 2001? Yesterday my project was working (at least the part that is already finished )but today when I tried to open it I got a 2001 runtime error ('you have interupted the operation'). If I click debug the following line turns yellow:

DoCmd.OpenForm "Hauptformular Projekt", acNormal, , , , acWindowNormal

where "Hauptformular Projekt" is my main form that should open automaticly when I begin the projekt. Also when I click on the black square in vb to end the form another message tells me that the autoexe makro doesn't work ....or something like this ( my vb is in german and I don't understand all of it, the same for the help).

I didn't chainge anything to the autoexe macro, nor to the main form...at least not volutarily......I have no ideea what has happened.....

Centre The Form On Printout?
I use Form1.Printform to print my form. But the form are placed on the left corner on the top of the paper. How can I centre the form when I printout?

VB6 And Access DoCmd Problem
I set a reference to the MS Access object libary, then I tried to run this report that prints labels:


Code:
Dim oApp As Access.Application

Set oApp = New Access.Application
oApp.OpenCurrentDatabase (conDb)
oApp.DoCmd.OpenReport "Customer Labels", acViewPreview, , , acWindowNormal


It doesn't print anything when I run it.
I don't get any errors but it locks up my IDE.

I really never use to "DoCmd" but I didn't want to design a label printing program using the VB6 printer object.

Any help will be greatly appreciated, thanks

Access/DoCmd Object
Hello all,

I am trying to copy a table under a different name in the same database through VB code.

1- Referencing (MSACC8.OLB)

2- code

Private Sub copy_tables()
Dim copy_Table As New Access.DoCmd
Dim dest_DB_Path As String

dest_DB_Path = "C:Backup_TablesBackup_Tables.MDB"
copy_Table.CopyObject dest_DB_Path, "Piece_Copy", acTable, "Piece"

End Sub


3- Error

Runtime 429
ActiveX Component Can not create object.


Can anyone help me with this? I have never used the DoCmd object from VB.


Also, is there a quick way to copy a table from one Access Database to another using VB??

Thanks
Hisham

Printout And Quit [Access/Word]
Hi, here is what I want to do. I have a access form that creates a word document with vba. I need to print this document and quit automatically because my document stays visible = false.
What I do is this:

Code:
' open the word document
' fill the document
' try to print
wdApp.ActiveDocument.PrintOut
wdApp.Quit wdDoNotSaveChanges
but word closes before to send my document to the printer. How can I wait after the printout? If I don't execute the last line it works, but I want thw word document to close.

Thanks!

Printout An Envelope In Access 2000
Hi all

I have been trying to find a way of printing an envelope based on the name and address of the current record in Access 2000

I tried using Mail Meerge from word, but that called up ALL the names and addresses in the DB.

I tried creating a report based on the size of the envelope, 110x220mm, but there were large white spaces based on the size of the text boxes.

There MUST be a way of printing out envelope and hope fully those in this forum will come up with an answer for me

Form Size For 8 1/2x11 Printout
Hi folks, I have a simple VB command that will run in some mapping software (Geomedia) we use. The command will open a form, allow the user to fill in some combo boxes and it takes a copy of the map in Geomedia and pastes it into a image box. All this works great but I then want to be able to print it out.

I have been reading some posts about printing and managed to get a decent output with my objects in the right places etc.... My question is, I want the output to fill an 8 1/2 x 11 page. So, is there a set size I need to make my form in VB to output to this this size or can I have the form smaller so the user can see it in the laptop screen and then print to 8 1/2 x 11? The application runs on laptops so my screen size it limited.

Any help would be great.

Thanks for your time.

Sherriff

Printing A MS Access Report Without DoCmd
I am trying to print an access report without actually opening the database and using the docmd action. The problem is, I require all users to log in to access, so the MS Access login box comes up. To the best of my knowledge, there is no way to autofil this box without sendkeys, and I hate sendkeys

This is what I have so far:

Code:
Function printreport()
Dim bigdatabase As Database
Dim docLoop As Document
Dim prpLoop As Property
Dim report1 As report

Set bigdatabase = OpenDatabase("T:accessDatabaseName.mdb")
Set report1 = bigdatabase.Containers("Reports").Documents("Report Name")
report1.Print
bigdatabase.Close
End Function

It doesn't work of course. I can pull the name of the report I want to print, I can pull the properties, I can set permissions, but can't print the darn thing. My head is going to explode!

Here is another function I wrote yesterday that someone may get some use out of. It runs an action query in an access database without opening a visible instance of access. At least this works :P


Code:
Function RunQinDB(RemoteDBPath As String, QueryName As String) As Boolean
On Error GoTo omgerror
Dim DB As Database
Dim query1 As QueryDef
Set DB = OpenDatabase(RemoteDBPath) 'DBEngine.Workspaces(0).
Set query1 = DB.QueryDefs(QueryName)
query1.Execute
RunQinDB = True
exit function
omgerror:
RunQinDB = False
End Function

Access 2002 Docmd.runsql
What's wrong with this....

SQL = "SELECT TOP 2 [tbl items].num_prj, [tbl items].qty, " & _
"[tbl items].description FROM [tbl items] " & _
"WHERE [tbl items].num_prj='903999'"

DoCmd.SetWarnings False
DoCmd.RunSQL SQL
DoCmd.SetWarnings True


help...

Printing An Access Report Without Using The DoCmd
Does any one know of a way to print an Access Report from VBA or a VB.DLL that does NOT use the DoCmd?





Edited by - mbaalman on 8/9/2006 9:28:56 AM

Import .csv-fil To Access (DoCmd.TransferText)
I've got a problem when trying to import data to Access using usin VB, and the TransferText-command which can be used in Access. I get a run-time error. Have anyone got an idea of how this can be done?


'[TableX] is tha table-name where the data should be imported to
Dim accessApp as Access.Application
Dim strDB as string
set accessApp = new Access.Application
strDB = [filename.csv]
accessApp.OpenCurrentDatabase strDB
accessApp.DoCmd.TransferText acImportDelim, , "TableX", strDB, -1
accessApp.CloseCurrentDatabase

Import .csv-fil To Access (DoCmd.TransferText)
I've got a problem when trying to import data to Access using usin VB, and the TransferText-command which can be used in Access. I get a run-time error. Have anyone got an idea of how this can be done?


'[TableX] is tha table-name where the data
'should be imported to
Dim accessApp as Access.Application
Dim strDB as string
set accessApp = new Access.Application
strDB = [filename.csv]
accessApp.OpenCurrentDatabase strDB
accessApp.DoCmd.TransferText _ acImportDelim, , "TableX", strDB, -1
accessApp.CloseCurrentDatabase

How To Genrate Report For VB Form For Taking Printout
hi
i am facing a problem in generating report for the form in VB.my form contains memo field of my acces database and when i tried generating reports using data enviroment, it gave an error Unspecified data length, and it doesnt displays emmo data fields in report. is there any other way to generate report.
Thanks in advance

Access Database DoCmd.OpenForm Concern
I am trying to do a simple openform command and am having some difficulties.


Code:
Private Sub Image51_Click()

On Error GoTo Err_Image51_Click

Open_Form:
Dim stOutreach As String
Dim stLink As String
stOutreach = "frmOutreach"
stLink = "[LogNum]=" & Me![LogNumtxtbox]
DoCmd.OpenForm stOutreach, acFormDS, , stLink, , acWindowNormal

Exit_Image51_Click:
Exit Sub

Err_Image51_Click:
MsgBox Err.Description
Resume Exit_Image51_Click

End Sub
My concern is this.
The code works just fine when the record in the current form displayed has data in it. However when I am on a new blank record (the autonumber field still says "(AutoNumber)" I get the error message "Syntax error (missing operator) in query expression '[LogNum]='.".

To resolve this I changed the following line to


Code:
stLink = "[LogNum]= '" & Me![LogNumtxtbox] & "'"
This fixes the problem with opening frmOutreach from a blank record but then creates the following error when clicking from an exisiting record.
"The OpenForm action was cancelled.
You used a method of the DoCmd object to carry out an action in Visual Basic, but then clicked Cancel in a dialog box.
For example..."

If it was just me I would be fine with the first set of code because I would know that the button doesn't work on a blank record (which I really don't want it to do). But if I don't fix it then I would have too many people calling me freaking out when they got the "syantax error" message.

Is there a way to create an If Then Else statement that can identify that the current record is truly blank (the autonumber has not yet been created)? From there I could post a message indicating you cannot click this on a blank record.


Thanks

DoCmd.CopyObject In Access - Compile Error
Hello! I'm trying to use the following line of code in my application:


Code:
AppAccess.DoCmd.CopyObject , "TotalStats1Day", actable, "TotalStats"


It will run fine from within the VB development environment. However, when I try to compile it I get a "Compile Error: Variable not defined" message and it points to the "actable" variable in that line of code. If I delete that variable name it will compile, but then it errors out when I run it.

I've done a lot of searching and cannot find any information that will help me in declaring that variable. Can anyone help me?

Thanks!

Docmd.SendReport In Access - Test Records
I have set up a function to send numerous reports out of a Access Database, but I would like write some code that tests to see if the query has any records. The If statement is easy, just finding the code to find the number of records is the hard part.

If me.qselRecords.... = 0 then
etc...

Help, I know this is probably soooo easy.

Sam

Access 2000 DoCmd.OpenReport Problems
Hi all,

Hope someone has the solutions to my problem.

How do I use the Where Clause of the DoCmd.OpenReport to accept 2 statements like:

ClassNo = "1E1" AND CourseTitle = "HTML"

I'm able to make it work by only ClassNo = "1E1" but when I add another selection filter, CourseTitle = "HTML", it doesn't work anymore and prompt me for the CourseTitle instead.

BTW, I'm picking up the 2 values from 2 combo boxes in a form.

Anyone knows how to solve this?

Thanks a lot!!

Access.OpenCurrentDatabase & DoCmd.. Password Issue
My database requires a password, how can I hard code the password into this sub?


Code:Private Sub ExportToExcel(strMdbPath As String, strExcelPath As String, strTable As String)
Dim AccessDB As Access.Application

    Screen.MousePointer = vbHourglass
    Set AccessDB = New Access.Application
    AccessDB.OpenCurrentDatabase strMdbPath, True
    
    AccessDB.DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
                                       strTable, strExcelPath, True
    AccessDB.Quit acQuitSaveNone
    Set AccessDB = Nothing
    Screen.MousePointer = vbDefault

End Sub
''must change this and make it dynamic.
Private Sub MDIForm_Unload(Cancel As Integer)

   ExportToExcel "C:SchedulerSchedulerSchedule.mdb", "C:Rotationally_Symmetric_Queue.xls", "Job"
   
End
End Sub

Hiding/showing Fields In Access Report PrintOut
Is there a way to hide or show individual fields in the "Detail" area of an MS Access report in function of the value of another field on the form??
TIA

Pagefile Limits Of Docmd.transfertext AcImportDelim -- Access
Nothing really challenging about this:


Code:


DoCmd.TransferText acImportDelim, IMPORTSPEC_MYTABLE, _
"MyTable", ImportFileName



At issue is the fact that I need to bring together nearly 750,000 records from several text file imports. Once I get over some magical number of around 500,000 records I start getting alerts:

Quote:
Your computer is out of disk space. You will not be able to undo.

Actually, this message is false and misleading. What it really suggests is that there is not enough page/swapfile space allocated to backup the existing data for undo. I can tell it to go ahead without undo, all is well (albeit slow). Even after making my pagefile swap the maximum possible size it still complains.

What I can't seemingly do is bypass this warning. I know of no method to explicitly tell Access to not automatically attempt an undo backup. Presently I am scratching my head to compromise without losing any (much) performance. Looping and inserting as a workaround seems incredibly wasteful.

I'm not really expecting a miracle solution, but thought I'd throw this out if anyone in fact does have suggestions.

Will DoCmd.SendObject Work Fine In Access 2k Integrating With Lotus Notes 5.0.5 Mailing
Hi

There is an existing application in access 97 using the following object to send a mail with the report as an attacment.

DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][, templatefile]

here lotus notes 5.0.5 server verson i used for mailing..

After upgarding the existing application to access 2k. the same piece of code is unable to send mail.

My question is... will the same line of code is compatible for sending mails through lotus notes 5.0.5.

if no what is the process...

waiting for ur valuable suggestions

Thanks
Suresh

Access "DoCmd.FindRecord" Problem
I am very new to Visual Basic and my boss needs me to sycronize to forms. The way i am trying to do it is my using DoCmd.Findrecord.... the code i am using is:

DoCmd.FindRecord F!txtProcess = [Process#]

I am geting a error during runtime that says "'findrecord' is not available now" Im not sure what this means and what i have missed....

Any help would be wonderful....

Thanx -- Ben

Need Printout
I have a form which asks user to input starting and ending number and the number is on 5 digits format.

If user enters 40051 to 40060, is there anyway I can get those 10 numbers printed?

Thanks in advance

Getting Printout
Guys,

How can I get 40 labels on a page. Actually I want to have 40 (5 Digits) number (10 in a column) on one page.

Can someone please tell me the way to get this done by using datareports.

Thanks in advance

Printout
Howcome everytime i print out it start from the 1st record? What should i do in order for me to print the current record not by setting the printer setup...    

I Hv Put Window Media Player In Its Own Form...and Try To Access It Form Anotehr Form???
my concept is put window media player into its own form...then i would like to access its from my other form....
for example, i hv 10 form.......i create new form which named is frm11, then i drap window media player from toolbox into frm11.....
then in each of my form(frm1 to frm10) have a button which named"movie"...
and i would like frm1 to frm10 access to frm11's window medai player to play movie clip .for example"dog movie" because each form movie clip is difference.....for example frm3 is cat movie clip...frm 8 is snake,,,,,etc

the reason i would like to put windox media player into frm11 only is becauce i if i attach wmp in each form...my program sleed will be affectd....

thansk for teach me how to slove it...
thanks !!!.

Printout At Outlook
hi

i want to print only email's fırst page with using vba, when new email come.

i can print all email with rules wizard. but it is printing all pages. we have a lot of mail. so this is very important for us.

please help urgly.

Using PrintOut In Excel
Hi,

I need to print an Excel sheet to a postscript file, and I'm using the PrintOut method to do this. But, I need to print the sheet to an already existing postscript file. Unfortunately, unlike Word's PrintOut method, Excel's PrintOut method does not have an append argument.

Anyone know of a workaround? Why doesn't Excel's PrintOut have an append argument?

Here's my line of code that does not work because append is not a valid argument:

Workbooks("testexcel.xls").Sheets("Sheet1").PrintOut printtofile:=True, _
prtofilename:="C: emp est.ps", append:= true

If you're curious, the reason I need to append to an already existing postscript file is that I'm creating a 2-page pdf report, where the 1st page is from a Word doc, and the 2nd page from an Excel doc. Thus, I need to write the Excel doc to a postscript file that I've already written the Word doc to.

Thanks a lot,
Jonathan

Centering The Printout
hi all
I want to print a form using printForm which contains some labels and images with orientation is landscape. but when I printed it gives an output left aligned on the paper.how can I do the centering of that form on the paper
please provide some idea


thanks and regard

ListBox Printout
Can anyone let me know how I printout a the context of a Listbox (named InOutStock) from a userform button. The current code below shows how I've got the actual contents into the (2 column) Listbox.


Code:
Private Sub OutStockItem_Click()

InOutStock.Clear
InOutStock.ColumnCount = 2

InOutStock.List = Worksheets("INOUT").rANGE("C2:D42").Value

End Sub

I want to add another buttpn to the userform that prints the contents brought up - ideally I'd like to specify the font etc of the printout.

Printout From Userform
Please Help.

I have been stuck on this problem for 3 weeks and for the life of me cannot work out how to do it.

I have a userform that creates a list of available worksheets to print. Users select which sheet/s that want to print, and the code does the rest.

The file is for workpapers. My problem lies in that the code selects and prints each sheet individually, which usually ends up clogging the print queue. Also, because each sheet is a separate print job, there is the potential problem of other print jobs being slotted between the workpapers. This is a problem because the workpapers must be printed on different coloured paper.

Is there a way to have the form collect all the selected sheets together and print them in a single print job?

Thank you in advance

Mikey.


P.S. The code that I currently have in place (along with a few changes) is:


Private Sub OKButton_Click()
Dim i As Integer
Dim Sheet As String

'Ensures operator has correct paper in printer.
Dim Msg As String
Msg = "Make sure that the correct" & vbCrLf
Msg = Msg & "colour paper is in the printer" & vbCrLf
Msg = Msg & "before continuing."
MsgBox Msg, vbExclamation, "About To Print Work Papers ..."

Application.ScreenUpdating = False

For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
'With Sheets(ListBox1.List(i))
'.PageSetup.PrintGridlines = cbGridlines
'If obLandscape Then .PageSetup.Orientation = xlLandscape
'If obPortrait Then .PageSetup.Orientation = xlPortrait
'.PrintOut
'End With
Sheet = Sheet & Selection(i)
End If
.PrintOut Copies:=1, Collate:=True
'ActiveSheet.Next.Select

Next i
Unload Me
End Sub

.PrintOut Append
Hello;

I am new to this forum and have tried search for an answer to this question but could not find one....

I am using the following line of code to print a .ps file (and eventually to a PDF):
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, ActivePrinter:="Acrobat Distiller", printtofile:=True, Collate:=True, prtofilename:=AttachmentFileName & ".ps"

I need to first create a unique file using the line of code above but then I need to append to it. I have seen reference to a "Append:=True" argument to .PrintOut but it doesn't seem to be an option for me. VB tells me the options are:

PrintOut([From],[To],[Copies],[Preview],[ActivePrinter],[PrintToFile],[Collate],[PrToFileName])

Any Ideas? How can I append to the .ps file before I create my final PDF?

Thanks,
Mike.

Want To Get Printout Tested, Please Help
Hi everybody,
I am planning to use the "Courier New" font for printing my reports using code, because it is proportional, character width remains the same when made bold and it contains box drawing characters. But before that, I want to make sure it prints OK on all printers. I have attached a zip file containing a rich-text file, in which I have two sample tables, one in 8 font size and the other in 10 font size. Please print it on your printer and let me know whether both the tables printed correctly. If not, let me know what is wrong. Also, let me know your printer type and model. I have tested in on my Epson LX-300 DotMatrix printer, on which it printed fine, except that it did not print bold in 8 font size. Your participation would be highly appreciated.

Editing The Printout
I try this code for datagrid printout.

Print DG

It works. Now I would like to put some caption above printed data like: "Records for Sunday..." Where should I put the code or text in code?? Any ideas? Thank you...

Pretty Printout
Can you folks recommend ways to make your printouts prettier or neater in VB? Currently the way I print is by using the Printer object.

-xmen64

Printout Of An .htm File
hi
I have an .htm File which contains lots of images
i want to preview that file and take the print of that file
Can any one suggest me any solution

Thanks
need quick reply

Printout Counter
Hello there

I wonder if anyone know a printout counter (a program that counts) the number of printing done on a printer
Which is made in VB?

Thanks in advance

Printout Cancel With Vb
when i printing a report , i want to flush the report when its printing, but i can't
i use printer.enddoc and printer.killdoc but still printing.
how can i do,
Thanks


Dim p As Object
Dim nn As String
For Each p In Printers
'If p.DeviceName = "HP DESKJET 840C/841C/842C/843C" Then
If p.DeviceName = "Lexmark Z55" And z55 = 1 Then
nn = "Lexmark Z55"
Set Printer = p
ElseIf p.DeviceName = "HP DeskJet 840C/841C/842C/843C" And hp = 1 Then
nn = "HP 840C"
Set Printer = p
End If
Next p
printer.print *****the report******
printer.killdoc

Graph Printout
Hi!

Does anybody know a good graph control or good
way to use a MSgraph for printout? Problem is that
MSgraph treates it's contents as bitmap and disorts
text when turning into 3D mode.

How To Design A Printout
What I am trying to do is to replace a paper form with lots of boxes. I was woundering if anyone knew of an easier way of doing this other than drawing boxes and putting text in them? I looked at vbextras and did mot see any controlls there that would allow me to do this. Any help would be great.

Thanks Scott

Font Changes In Printout
HI,
I set the fonts for all my labels as ms-sans serif and the form appears pretty well on screen but when i print out, the font is changed to century gothic.(labels especially). what is the reason for this and how can I correct it ? Also the text in text boxes are printed gray not black. please help.
thanks.

Printout Problem !!
Hi Pals !
  i want my VB application to keep records of each and every print out taken from the system on which my application is installed.
  Please can somebody suggest me the solution?

 

Document.PrintOut
Hi,

I want to print a Word document (.doc) to a pdf file. So I open the Word document in VB and use the .PrintOut method to print. If I don't provide any parameters to the PrintOut method, a dialog box pops up and I save a file in a specified place. Later I open the file and it all looks good. But as soon as I provide parameters to the PrintOut method, a pdf file is produced (in the location I specify in the parameters), but it cannot be opened. It says that it might be damaged. Do you have any clue on what it might be?
Grateful for help!

Taking Printout
hai guru's

i am beginner.is it possible to take printout of form design ? if so can anyone tell me how to take that.Thanks.


tvel

DoCmd And Do Until
I would like to create a clear button that clears 4 check boxes (in Access.) Originally this wasn't a problem a table was used and I had the code:

Me.Recordset.MoveFirst

Do Until Me.Recordset.EOF
chk1.value=0
chk2.value=0
chk3.value=0
chk4.value=0
Me.Recordset.MoveNext
Loop

But now, instead of a table, the customer would like to use a query. I'm sure this is just as simple, but I can't figure out how the code would work. I have never used queries before and looking at it, it looks like DoCmd is used, but I'm not sure how you could loop with the DoCmd.

Any help would be appreciated.

Thanks

Docmd
hi,

i am moving an application from Access to VB6 and SQL server. I have the following line of code and was wondering if there is an easy way to convert it to be able to work with the new system


Code:
DoCmd.TransferText acExportDelim, "DailyDDCollection", "tblDailyDDCollection", strFileToSaveAs


I am using ADO 2.7 by the way

cheers
nick

DoCMD?
Hi All,

Can anyone tell me what does this DoCMD Mean? Where do I use it exactly and when?

Thanks,

Venkat.

Docmd In Vb
Hi all,
I am using the followinf code for import dbf files to mdb in one shot, but i am not able to inderstand ths 'docmd' object can any one please help me in this.


Regards
John Philip
----------------------------------------
Dim con As ADODB.Connection
    Dim rst As ADODB.Recordset

    Set con = New ADODB.Connection
    Set rst = New ADODB.Recordset
    con.Open "accounts", , strDatapwd
    rst.Open "tblBatchImport", con, adOpenForwardOnly, adLockOptimistic
    Set doCmd = CreateObject("access.doCmd")
    Me.MousePointer = 11

    rst.MoveFirst

    Do Until rst.EOF
        
        doCmd.TransferDatabase acImport, rst("TableType"), _
              rst("SourceDirectory"), acTable, rst("SourceDatabase"), _
              rst("ImportName"), False
        rst.MoveNext
    Loop

    rst.Close

***  Even the Best, did the Bad and Made the Best ***

John Philip


Need Help Using DoCmd In VB
I am trying to use the DoCmd object in VB to open a form and to run a macro in Microsoft access, but I keep getting
undefined variable when I code as follows:
DoCmd.RunMacro "mymacro"
or
DoCmd.openform "myform"

It is like visual basic does not recognize the docmd object

Copyright 2005-08 www.BigResource.com, All rights reserved