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 / January 2007

Tip: Looking for answers? Try searching our database.

VBA programming - Loop Coding Question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michele - 29 Jan 2007 20:14 GMT
I'm having problem with the Loop VBA code within a macro.  I'm running
something that produces reports based on ssn/names for each entry in a form.  
Here's my code:

THIS ONE DOESN’T WORK:
Function Export_Statement()
On Error GoTo Export_Statement_Err

DoCmd.OpenReport "Rpt-Account Statement", acViewPreview, "", "[SS Number] =
[Forms]![frm_statements]![SSN]", acNormal
DoCmd.OutputTo acReport, "Rpt-Account Statement", "SnapshotFormat(*.snp)",
"X:\Rewards Domain\Compensation Administration\BP\Statements\" &
[Forms]![frm_statements]![Last Name] & "_" & [Forms]![frm_statements]![First
Name] & ".snp", False, "", 0
DoCmd.Close acReport, "Rpt-Account Statement"
DoCmd.GoToRecord acForm, "frm_statements", acNext

Export_Statement_Exit:
 Exit Function
 
Export_Statement_Err:
 MsgBox Error$
 Resume Export_Statement_Exit

End Function

However, it keeps halting saying it doesn't recognize the form.  However, if
I remove the line first conditional stmt or hardcode the ssn instead, it runs
fine.  Any thoughts?

I bascially copied a previous VBA Code that ran beautifully in a different
macro which is a follows:

THIS ONE WORKS IN ANOTHER DB:
Function Export_Statement()
On Error GoTo Export_Statement_Err

DoCmd.OpenReport "*Commission Sheets - Export", acViewPreview, "",
"[id]=[forms]![frm_id for export]![id] and [home site]=[forms]![frm_id for
export]![site]", acNormal
DoCmd.OutputTo acReport, "*Commission Sheets - Export",
"SnapshotFormat(*.snp)", [Forms]![frm_id for export]![Location] & "Current
Activity Statements\" & [Forms]![frm_id for export]![id] & ".snp", False, "",
0
DoCmd.Close acReport, "*Commission Sheets - Export"
DoCmd.GoToRecord acForm, "frm_id for export", acNext

Export_Statement_Exit:
 Exit Function
 
Export_Statement_Err:
 MsgBox Error$
 Resume Export_Statement_Exit

End Function

I'm baning my head against a brick wall so any help would be greatly
appreciated.

Thanks!
Michele
Perry - 29 Jan 2007 22:41 GMT
>> DoCmd.OpenReport "Rpt-Account Statement", acViewPreview, "", "[SS Number]
>> =
>> [Forms]![frm_statements]![SSN]", acNormal

DoCmd.OpenReport "Rpt-Account Statement", acViewPreview, "", "[SS Number] =
" & _
Chr(34) & [Forms]![frm_statements]![SSN] & Chr(34), acNormal

Krgrds,
Perry

> I'm having problem with the Loop VBA code within a macro.  I'm running
> something that produces reports based on ssn/names for each entry in a
[quoted text clipped - 63 lines]
> Thanks!
> Michele
 
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.