D
DawnP277
I have a basic form, that is bound to a table.
The user are to enter information about a particular block. Once they enter
a work order number I have the system create a block number. This works find.
However once you save the record it is changing the block number on the table.
for instance on the form after update on work order the block number is
generated. this works correctly.
Then when done they click the print button that saves the record and then
prints out labels.
However when you go back to the table the block number has been increased by
one.
For example on the screen it will show the block number to be 016C1109 but
when you go to the table the number is 017C1109.
I will provide the code below.. If anyone can figure out why this is
happening I would be greatful.
Dawn
Here is the code for generating the block number:
Private Sub WorkOrder_Exit(Cancel As Integer)
Dim WLength As Variant
Dim TMonth As String
Dim MonthMsg As Variant
Dim TYear As Variant
Dim Sheeter As Variant
Dim Block As Variant
Dim section As Variant
Dim cBlock As Variant
Dim count1 As Variant
WLength = Len(Me.WorkOrder)
If WLength <> 6 Then
Cancel = True
MsgBox "Work Order has been entered incorrectly"
Exit Sub
Else
Sheeter = Me.Sheeter
If Sheeter = "N" Or Sheeter = "K" Then
TMonth = Format(Date, "MM")
TYear = Format(Date, "YY")
section = Me.Block_Section
Block = CStr(TMonth & TYear)
Me.Text9 = Block
'Assigning crates values to verify that are not null
count1 = Forms![SheeterInfo]![Text9]
cBlock = DCount("[ID]", "BlockCount", _
"[BlockCount] = '" & count1 & "'")
cBlock = Format(cBlock + 1, "000")
Me.BlockNumber = (cBlock & Sheeter & Block & section)
Else
TMonth = Format(Date, "MM")
TYear = Format(Date, "YY")
Block = CStr(TMonth & TYear)
Me.Text9 = Block
'Assigning crates values to verify that are not null
count1 = Forms![SheeterInfo]![Text9]
cBlock = DCount("[ID]", "BlockCount", _
"[BlockCount] = '" & count1 & "'")
cBlock = Format(cBlock + 1, "000")
Me.BlockNumber = (cBlock & Sheeter & Block)
End If
End If
End Sub
Here is the code for printing the block number reports:
Private Sub Command8_Click()
'Save record and print out reports
Dim TMonth As String
Dim MonthMsg As String
Dim TYear As String
Dim Sheeter As String
Dim Block As Variant
Dim cBlock As Variant
Dim count1 As Variant
'Verify that a choice has been made in the sheeter
If Me.Sheeter.ListIndex = -1 Then
MsgBox "You need to choose a a sheeter"
Me.Sheeter.SetFocus
Exit Sub
End If
'Verify shift has been entered
If Me.Shift.ListIndex = -1 Then
MsgBox "you need to enter your shift"
Me.Shift.SetFocus
Exit Sub
End If
'Verify Employee is filled in
Me.Employee.SetFocus
'check the combo box
If IsNull(Me.Employee) Then
MsgBox "Must entred your name"
Me.Employee.SetFocus
Exit Sub
End If
'Verify Work Order has been entered
Me.WorkOrder.SetFocus
If (Me.WorkOrder.Text = "") Then
MsgBox "You Must Enter a Work Order"
Me.WorkOrder.SetFocus
Exit Sub
End If
'save record
DoCmd.RunCommand acCmdSaveRecord
'Open report in Preview mode
DoCmd.OpenReport "BlockLabel", acViewPreview
'Print out specified number of report copies
DoCmd.PrintOut , , , , 1
DoCmd.Close acReport, "BlockLabel", acSaveNo
'PRint Block Card Label
DoCmd.OpenReport "BlockCard"
DoCmd.Close acReport, "BlockCard", acSaveNo
'DoCmd.GoToRecord acDataForm, "SheeterInfo", acNewRec
DoCmd.Close acForm, "SheeterInfo"
DoCmd.OpenForm "SheeterInfo"
End Sub
The user are to enter information about a particular block. Once they enter
a work order number I have the system create a block number. This works find.
However once you save the record it is changing the block number on the table.
for instance on the form after update on work order the block number is
generated. this works correctly.
Then when done they click the print button that saves the record and then
prints out labels.
However when you go back to the table the block number has been increased by
one.
For example on the screen it will show the block number to be 016C1109 but
when you go to the table the number is 017C1109.
I will provide the code below.. If anyone can figure out why this is
happening I would be greatful.
Dawn
Here is the code for generating the block number:
Private Sub WorkOrder_Exit(Cancel As Integer)
Dim WLength As Variant
Dim TMonth As String
Dim MonthMsg As Variant
Dim TYear As Variant
Dim Sheeter As Variant
Dim Block As Variant
Dim section As Variant
Dim cBlock As Variant
Dim count1 As Variant
WLength = Len(Me.WorkOrder)
If WLength <> 6 Then
Cancel = True
MsgBox "Work Order has been entered incorrectly"
Exit Sub
Else
Sheeter = Me.Sheeter
If Sheeter = "N" Or Sheeter = "K" Then
TMonth = Format(Date, "MM")
TYear = Format(Date, "YY")
section = Me.Block_Section
Block = CStr(TMonth & TYear)
Me.Text9 = Block
'Assigning crates values to verify that are not null
count1 = Forms![SheeterInfo]![Text9]
cBlock = DCount("[ID]", "BlockCount", _
"[BlockCount] = '" & count1 & "'")
cBlock = Format(cBlock + 1, "000")
Me.BlockNumber = (cBlock & Sheeter & Block & section)
Else
TMonth = Format(Date, "MM")
TYear = Format(Date, "YY")
Block = CStr(TMonth & TYear)
Me.Text9 = Block
'Assigning crates values to verify that are not null
count1 = Forms![SheeterInfo]![Text9]
cBlock = DCount("[ID]", "BlockCount", _
"[BlockCount] = '" & count1 & "'")
cBlock = Format(cBlock + 1, "000")
Me.BlockNumber = (cBlock & Sheeter & Block)
End If
End If
End Sub
Here is the code for printing the block number reports:
Private Sub Command8_Click()
'Save record and print out reports
Dim TMonth As String
Dim MonthMsg As String
Dim TYear As String
Dim Sheeter As String
Dim Block As Variant
Dim cBlock As Variant
Dim count1 As Variant
'Verify that a choice has been made in the sheeter
If Me.Sheeter.ListIndex = -1 Then
MsgBox "You need to choose a a sheeter"
Me.Sheeter.SetFocus
Exit Sub
End If
'Verify shift has been entered
If Me.Shift.ListIndex = -1 Then
MsgBox "you need to enter your shift"
Me.Shift.SetFocus
Exit Sub
End If
'Verify Employee is filled in
Me.Employee.SetFocus
'check the combo box
If IsNull(Me.Employee) Then
MsgBox "Must entred your name"
Me.Employee.SetFocus
Exit Sub
End If
'Verify Work Order has been entered
Me.WorkOrder.SetFocus
If (Me.WorkOrder.Text = "") Then
MsgBox "You Must Enter a Work Order"
Me.WorkOrder.SetFocus
Exit Sub
End If
'save record
DoCmd.RunCommand acCmdSaveRecord
'Open report in Preview mode
DoCmd.OpenReport "BlockLabel", acViewPreview
'Print out specified number of report copies
DoCmd.PrintOut , , , , 1
DoCmd.Close acReport, "BlockLabel", acSaveNo
'PRint Block Card Label
DoCmd.OpenReport "BlockCard"
DoCmd.Close acReport, "BlockCard", acSaveNo
'DoCmd.GoToRecord acDataForm, "SheeterInfo", acNewRec
DoCmd.Close acForm, "SheeterInfo"
DoCmd.OpenForm "SheeterInfo"
End Sub