Record not saving correctly

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
 
J

Jeff Boyce

Are you saying that when the system leaves the form and goes to the report,
the block number is incremented by 1?

Isn't that exactly what your code is telling Access to do? Perhaps you want
to use something other than the OnExit event?


Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

DawnP277 said:
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
 
D

DawnP277

No when the report prints it is correct it is when it goes to the table it
changes the block number.

i di move the code out of OnExit tot he print button and that seems to have
solved it.

I just do not understand why it was doing that.

Dawn
Jeff Boyce said:
Are you saying that when the system leaves the form and goes to the report,
the block number is incremented by 1?

Isn't that exactly what your code is telling Access to do? Perhaps you want
to use something other than the OnExit event?


Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

DawnP277 said:
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


.
 
J

Jeff Boyce

Because when you left the form to go to the report, the code ran and
incremented your value.

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

DawnP277 said:
No when the report prints it is correct it is when it goes to the table it
changes the block number.

i di move the code out of OnExit tot he print button and that seems to
have
solved it.

I just do not understand why it was doing that.

Dawn
Jeff Boyce said:
Are you saying that when the system leaves the form and goes to the
report,
the block number is incremented by 1?

Isn't that exactly what your code is telling Access to do? Perhaps you
want
to use something other than the OnExit event?


Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or psuedocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

DawnP277 said:
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


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top