jd_boss_hogg
Registered User.
- Local time
- Today, 16:56
- Joined
- Aug 5, 2009
- Messages
- 88
Hi all - i've copied this code from somewhere (can't rememebr, but may even have been this forum?) and then butchered it to fit my needs. I'm completely new to VBA coding, and can tell that it's not structured correctly, but can't seem to get it to work.
If the user hits the correct password, then the open query/write file.close query works, then the open report/print works fine, but i just can't get the last query to do anything. I get no erro messages, but it's as though this ine fails to run... DoCmd.OpenQuery "NewCsvNotExported"
Also, the sub routine "export_invoice_err" actually runs as aprt of the main "if" loop, and not when there is an error, so i know i'm missing something somewhere !
Hoping someone can help? Thanks !
Code:
Private Sub Command18_Click()
On Error GoTo Export_Invoice_Err
Dim strPasswd
strPasswd = InputBox("Enter Password", "Restricted Form")
If strPasswd = "" Or strPasswd = Empty Then
MsgBox "No Input Provided", vbInformation, "Required Data"
Exit Sub
End If
If strPasswd = "fred" Then
DoCmd.OpenQuery "NewCsvExport", acViewNormal, acReadOnly
DoCmd.TransferText acExportDelim, , "NewCSVExport", "C:\sageexport\Sage_Export_" & Format(Now, "yyyymmdd") & ".csv"
DoCmd.Close acQuery, "NewCsvExport"
DoCmd.OpenReport "Invoices_to_sage"
DoCmd.SelectObject acReport, "Invoices_to_sage"
DoCmd.PrintOut acSelection
DoCmd.OpenQuery "NewCsvNotExported"
Forms!new_csv_Export!.Refresh
Else
MsgBox "Sorry, you do not have access to this form", _
vbOKOnly, "Important Information"
Exit Sub
End If
Export_Invoice_Err:
MsgBox "All Done !"
End Sub
If the user hits the correct password, then the open query/write file.close query works, then the open report/print works fine, but i just can't get the last query to do anything. I get no erro messages, but it's as though this ine fails to run... DoCmd.OpenQuery "NewCsvNotExported"
Also, the sub routine "export_invoice_err" actually runs as aprt of the main "if" loop, and not when there is an error, so i know i'm missing something somewhere !
Hoping someone can help? Thanks !