Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2007

Tip: Looking for answers? Try searching our database.

Closing and re-opening forms on exit

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin - 22 Oct 2007 01:02 GMT
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.
I use an "Udate" command in the form, and i need to write the date before i
go to the start of the form again
Signature

Many Thanks
Kevin

fredg - 22 Oct 2007 01:15 GMT
> 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.
> I use an "Udate" command in the form, and i need to write the date before i
> go to the start of the form again

You don't need to close then re-open the form just to save the data.
Code a command button:

DoCmd.RunCommand acDmdSaveRecord

Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Kevin - 22 Oct 2007 02:01 GMT
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
John W. Vinson - 22 Oct 2007 03:10 GMT
>> 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]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.