I am not sure if this would belong in the VBA, Query or Forms sub-forum so if I got it wrong sorry!
I have run into a problem in my wire cutting program where footage is being deducted incorrectly. Below is a snip of the sub-form.
The sub-form is a continuous form to display all cuts for this particular type of wire for this order. When the wire guy selects which reel he is going to cut it from (the combo box), he typically selects all the lengths at once and then prints each one. However it appears when that is done, the module that handles the printing of the labels deducts the footage for each line every time the print button is click rather than just that particular line.
I assume this a due to the nature of a continuous form in that all controls shown are technically the same control. Should I have used a different kind of form to display this? Continuous is what made the most sense but is proving to be a troubleshooting nightmare. Below is the code for the print button for reference. Currently several lines are commented out for testing so I am not printing needlessly and opening up the report when it isn't needed.
I have run into a problem in my wire cutting program where footage is being deducted incorrectly. Below is a snip of the sub-form.
The sub-form is a continuous form to display all cuts for this particular type of wire for this order. When the wire guy selects which reel he is going to cut it from (the combo box), he typically selects all the lengths at once and then prints each one. However it appears when that is done, the module that handles the printing of the labels deducts the footage for each line every time the print button is click rather than just that particular line.
I assume this a due to the nature of a continuous form in that all controls shown are technically the same control. Should I have used a different kind of form to display this? Continuous is what made the most sense but is proving to be a troubleshooting nightmare. Below is the code for the print button for reference. Currently several lines are commented out for testing so I am not printing needlessly and opening up the report when it isn't needed.
Code:
Private Sub PrintLabelBtn_Click()
Dim i As Integer
Dim x As Integer
'if flagged complete ask if reprint is needed
If Me.SingleComplete = True Then
If MsgBox("Print new label?", vbYesNo, "Reprint Label") = vbYes Then
'ask if reels need updated
If MsgBox("Do you want to deduct footage from choosen reel?", vbYesNo) = vbYes Then
If Me.SingleCmb = 0 Then
MsgBox "No reels selected. Please select a reel"
Exit Sub
End If
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryLogSingleCut"
DoCmd.OpenQuery "QryUpdateCutLogLengthSingles"
DoCmd.OpenQuery "UpdateWireRmSingle"
DoCmd.SetWarnings True
GoTo LinePrint
End If
'if reels do not need updated, jump to print
GoTo LinePrint
Else
If MsgBox("Do you want to deduct footage from choosen reel?", vbYesNo) = vbYes Then
If Me.SingleCmb = 0 Then
MsgBox "No reels selected. Please select a reel"
Exit Sub
End If
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryLogSingleCut"
DoCmd.OpenQuery "QryUpdateCutLogLengthSingles"
DoCmd.OpenQuery "UpdateWireRmSingle"
DoCmd.SetWarnings True
Exit Sub
Else
'user chose not to reprint label and not update wire, exit sub
Exit Sub
End If
Exit Sub
End If
End If
If Me.SingleCmb = 0 Then
'do nothing to prevent blank logs
If MsgBox("No wire has been selected. Please cancel if done in error.", vbOKCancel, "Select Wire") = vbCancel Then
MsgBox "Operation cancelled", vbOKOnly
Exit Sub
End If
Else
DoCmd.SetWarnings False
DoCmd.OpenQuery "QryLogSingleCut"
DoCmd.OpenQuery "QryUpdateCutLogLengthSingles"
DoCmd.OpenQuery "UpdateWireRmSingle"
DoCmd.SetWarnings True
End If
LinePrint:
If Me.CutNum >= 1 Then
If Me.CutNum > 1 And MsgBox("Do you want to print multiples of this label?", vbYesNo) = vbYes Then
i = CInt(InputBox("Please enter the number of copies"))
For x = 1 To i Step 1
'DoCmd.OpenReport "rptSingleCutLbl", acViewPreview, , "SingleID=" & Me.SingleID
'Reports!rptSingleCutLbl.Controls!FirstNumTxt.Value = x
'Reports!rptSingleCutLbl.Controls!LastNumTxt.Value = i
'DoCmd.PrintOut
Next x
'DoCmd.Close acReport, "rptSingleCutLbl"
Else
'DoCmd.OpenReport "rptSingleCutLbl", acViewPreview, , "SingleID=" & Me.SingleID
'Reports!rptSingleCutLbl.Controls!FirstNumTxt.Value = 1
'Reports!rptSingleCutLbl.Controls!LastNumTxt.Value = 1
'DoCmd.PrintOut
'DoCmd.Close acReport, "rptSingleCutLbl"
End If
End If
Forms!frmWireRoom.SetFocus
Me.SingleComplete = True
Me.Requery
Me.Refresh
End Sub