
Signature
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Hi Fredg
I inserted the code as required, but it still didn't update the record, I
have posted the code, if you can have a quick look as i must be doing
something wrong.
Private Sub QTY_Exit(Cancel As Integer)
If Me.JobnumbersID = 11041 Then
Me.tempqty = Me.QuantityInStock + Me.QTY
Me.QuantityInStock = Me.tempqty
DoCmd.RunSQL "UPDATE[stock] set [quantityinstock]=" & Me.QuantityInStock
& " where [stocknumberID]=" & Me.StockNumberID
DoCmd.RunCommand acCmdSaveRecord
DoCmd.RunCommand acCmdSaveRecord
Else: Me.tempqty = Me.QuantityInStock - Me.QTY
QuantityInStock = Me.tempqty
DoCmd.RunSQL "UPDATE[stock] set [quantityinstock]=" &
Me.QuantityInStock & " where [stocknumberID]=" & Me.StockNumberID
Me.tempqty = 0
DoCmd.RunCommand acCmdSaveRecord
End If
Me.tempqty = 0
DoCmd.RunCommand acCmdSaveRecord
End Sub

Signature
Many Thanks
Kevin
> > Is there any method that when i exit a field on a form, that i canon the exit
> > button tell the form to close and automatically reopen again.
[quoted text clipped - 5 lines]
>
> DoCmd.RunCommand acDmdSaveRecord
>> Is there any method that when i exit a field on a form, that i canon the exit
>> button tell the form to close and automatically reopen again.
[quoted text clipped - 5 lines]
>
>DoCmd.RunCommand acDmdSaveRecord
tiny typo: acCmdSaveRecord.
An alternative syntax to save the record is
If Me.Dirty Then Me.Dirty = False
John W. Vinson [MVP]
Kevin - 22 Oct 2007 04:37 GMT
I tried both these methods and it did not write the data back to the file,
When i go the the next add record the quantity has not been written to, it
only appears to write it when i exit the form and re-enter the form. Then the
data is written
to the file
--
Many Thanks
Kevin
> >> Is there any method that when i exit a field on a form, that i canon the exit
> >> button tell the form to close and automatically reopen again.
[quoted text clipped - 13 lines]
>
> John W. Vinson [MVP]
Kevin - 22 Oct 2007 04:43 GMT
I am sorry i mislead everyone on my problem, The data is been written to the
file, but unless i close the form and re-open the form, the updated data is
not correct. EG if i add 200 of item 10605 the total changed to 800, and if
i then re-enter more data the total stayes at 600 not the updated amount of
800. So what i really need to do is refresh the data each time i finish
entering datat in a form, before i enter the next lot of data into the form

Signature
Many Thanks
Kevin
> >> Is there any method that when i exit a field on a form, that i canon the exit
> >> button tell the form to close and automatically reopen again.
[quoted text clipped - 13 lines]
>
> John W. Vinson [MVP]
John W. Vinson - 22 Oct 2007 07:30 GMT
>I am sorry i mislead everyone on my problem, The data is been written to the
>file, but unless i close the form and re-open the form, the updated data is
>not correct. EG if i add 200 of item 10605 the total changed to 800, and if
>i then re-enter more data the total stayes at 600 not the updated amount of
>800. So what i really need to do is refresh the data each time i finish
>entering datat in a form, before i enter the next lot of data into the form
This isn't making sense. What is the Recordsource for the form? Are you doing
calculations in the form? If so, how? what expressions? What are the Control
Sources for the totals fields?
John W. Vinson [MVP]
steve - 22 Oct 2007 12:52 GMT
It seems to me that if you add the following to John Vinson's post it might
do what you want.
after
If Me.Dirty Then Me.Dirty = False
add
Me.Requery
This will cause the form to refresh with the current data.
HTH
Steve
>>> Is there any method that when i exit a field on a form, that i canon the
>>> exit
[quoted text clipped - 15 lines]
>
> John W. Vinson [MVP]
John W. Vinson - 22 Oct 2007 17:54 GMT
>It seems to me that if you add the following to John Vinson's post it might
>do what you want.
[quoted text clipped - 7 lines]
>
>HTH
Thanks Steve! You're very likely correct.
John W. Vinson [MVP]