Selasa, 23 April 2013

[MS_AccessPros] Write conflict: help with code

 

Hello friends,

I need some help making this code work smoothly. Currently, it is working but when the procedure runs it returns a write conflict error and I have to choose to save record, copy to clipboard or drop changes and it is not clearing the text box for comments.

Here is what I want the code to do:
Check for a unit number in a combo box named List4, if one is there
check for a delivery location in combo box, cboDelLocation, then check to see if the shipping docs have already been printed by looking at a yes/no control, ShipDocsPrinted. If no, print the shipping docs. If yes, prompt the user to either print again or exit. Finally, I want the Shipping docs print flag upated to yes after the shipping docs are printed. Here is the code:

Private Sub Command6_Click()
On Error GoTo Err_Command6_Click

'Check for Unit Number
If IsNull(Me.List4) Then
Call MsgBox("Please select a valid unit number before printing.", vbExclamation, "No Unit Number Selected")
Me.List4.SetFocus
Exit Sub
End If


'check for Delivery Location
If IsNull(Me.cboDelLocation) Then
Call MsgBox("Please select a valid delivery location.", vbExclamation, "No Delivery Location Selected")
Me.cboDelLocation.SetFocus
Exit Sub
End If

'check to see if ship docs have already been printed
If Me.ShipDocsPrinted = -1 Then
Select Case MsgBox("Shipping documents have already been printer for this trailer. " _
& vbCrLf & "Do you want to print them again?" _
, vbYesNo Or vbQuestion Or vbDefaultButton2, Application.Name)

Case vbYes
GoTo PrintShipDoc
Case vbNo
Me.List4.SetFocus
Exit Sub
End Select
End If

PrintShipDoc:
'Print Shipping Document
Dim stDocName As String

stDocName = "rptShippingDoc"
DoCmd.OpenReport stDocName, acNormal

'Update Print Flag
Dim stQryName As String
stQryName = "qryUpdateNewShippingDocPrinted"
DoCmd.OpenQuery stQryName, acViewNormal

Me.Refresh
Me.txtComments = Null
Me.List4.SetFocus

Exit_Command6_Click:
Exit Sub

Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub

the SQL for "qryUpdateNewShippingDocPrinted" is:

UPDATE tblTruckloadPrimary SET tblTruckloadPrimary.ShipDocsPrinted = True
WHERE (((tblTruckloadPrimary.[New Unit #])=[Forms]![frmPrintShippingDoc]![List4]));

Thanks in advance.

Doyce

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
Recent Activity:
MARKETPLACE


.

__,_._,___

Tidak ada komentar:

Posting Komentar