Advertisement
Advertisement
| 07.08.2008 at 01:52PM PDT, ID: 23548268 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: |
Private Sub cmd_Export_Click()
Dim frm_VPD As String
Dim Title As String
Title = Me.cbo_title.Value
Dim x As Long
Dim cnConnection As ADODB.Connection
Set cnConnection = New ADODB.Connection
Dim rsInvoice As ADODB.Recordset
x = getInvoiceNum
Set rsInvoice = New ADODB.Recordset
With rsInvoice
.Open "UPDATE tbl_VPDOrdersPlaced SET tbl_VPDOrdersPlaced.InvoiceNumber = x", CurrentProject.Connection
End With
Do Until rsInvoice.EOF
rsInvoice.MoveNext
Loop
rsInvoice.Close
Set rsInvoice = Nothing
Dim strConnection As String
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & CurrentProject.Path & "\Studio Resale.mdb;"
cnConnection.Open strConnection
Dim sSql As String
sSql = "SELECT tbl_VPDOrdersPlaced.* INTO [" & Title & "_" & Format(Date, "mmddyy")
sSql = sSql & "]FROM tbl_VPDOrdersPlaced "
cnConnection.Execute sSql
DoCmd.TransferText acExportDelim, , "tbl_VPDOrdersPlaced", "\\cyclone\documents\ryan.bass\Studio Resale\" & [Title] & ".txt"
DoCmd.SetWarnings False
DoCmd.OpenQuery "DeleteOrders"
DoCmd.SetWarnings True
End Sub
Private Function getInvoiceNum()
Dim MaxInvNo As Long, curVal, newVal
If Nz(DMax("InvoiceNumber", "tbl_VPDOrdersPlaced"), "") = "" Then
newVal = Nz(DMax("InvoiceNumber", "tbl_InvoiceNumber"))
Else
curVal = Nz(DMax("InvoiceNumber", "tbl_VPDOrdersPlaced"))
MaxInvNo = Mid(curVal, 2)
newVal = Left(curVal, 1) & MaxInvNo + 1
End If
getInvoiceNum = newVal
End Function
|