Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Previewing Access reports from Visual Basic

Status
Not open for further replies.

scubagirl

Technical User
Jul 30, 2000
1
US
Hi.<br><br>I am actually a student, but that option was not available when I signed up.&nbsp;&nbsp;So....<br><br>I have a question I am desperately hoping someone can help me with.&nbsp;&nbsp;I am trying to finish the final project in my first VB class and need to preview/print a report I created in an Access database by clicking a specific command button.&nbsp;&nbsp;I believe some of the code I have right, but am missing a filter name and a where condition.&nbsp;&nbsp;The code I have written is below.<br><br>If Value.opttaoffice = Ture Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim objAccess As Access.Application<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set objAccess = New Access.Application<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objAccess.OpenCurrentDatabase (&quot;a:\Invoice Log.mdb&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objAccess.DoCmd.OpenReport (&quot;District Office Turn Around&quot;,[view as AcView=acViewNormal],<b>[filter][where condition]</b>)<br>&nbsp;&nbsp;&nbsp;&nbsp;ElseIf Value.opttotta = True Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim objAccess As Access.Application<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set objAccess = New Access.Application<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objAccess.OpenCurrentDatabase (&quot;a:\Invoice Log.mdb&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;objAccess.DoCmd.OpenReport (&quot;Total Turn Around&quot;,[view as AcView=acViewNormal],<b>[filter][where condition]</b>)<br><br>If anyone can help me, I would greatly appreciate it.<br><br>Thank you so much!<br><br>Jamie<br><br>
 
Jamie,<br><br>This is certainly NOT the whole answer, however the 1st code line, you have mis-typed TRUE (as ture).<br><br>Next observation is you have included square brackets around parts of the &quot;commands&quot; - perhaps as &quot;reminders&quot; to us that this is where you suspect problem(s) - if not, then you should be aware that they are not necessary (or even useful).&nbsp;&nbsp;I beleive &quot;view as AcView=acViewNormal&quot; should JUST be &quot;acViewNormal&quot;, but have not done this in a while, so I am not sure.<br><br>I have never used both &quot;Filter&quot; & &quot;Where&quot; together, however this could easily result in a null report, so you need to be very careful with this.&nbsp;&nbsp;Otherwise, the &quot;Where&quot; part looks like the &quot;Where&quot; clause of SQL, without the word &quot;Where&quot;.&nbsp;&nbsp;Hope this helps some.<br><br>Michael<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top