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 / General 2 / May 2007

Tip: Looking for answers? Try searching our database.

doCmd.Requery

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Amateur - 21 May 2007 12:08 GMT
I do have the following

1)    a form called “customers”
2)    a subform in the “customers” form, called “billsopenvalue”(Datasheet)
3)    a field in the the form “billsopenvalue” is called “resting”
4)    a Form called “receivedpayments” with a field named “”paymentamount”

What I would like to do:

If I change in the “receivedpayments” form the field “paymentamount”, the
the field “resting” in the “customers”forms  subform “billsopenvalue” should
be changed automatically.

What did I do:

I tried to run an “afterUpdate” doCmd in the field “paymentamount” of the
receivedpayments” form.

Like this:
Private Sub paymentamount_AfterUpdate()
DoCmd.Requery “Forms!customers!billsopenvalue.resting”
End Sub

Result:

Run-time error ‘2109’
There is no field named ‘Forms’customers!billsopenvalue.resting’ in the
current record.

BUT in the subform “billsopenvalue” of the form “customers” is the field
named ”resting”.

Has someone an idea how I can change my code so that it is running like I
described above?
Thanks
Klaus
richard harris - 21 May 2007 12:23 GMT
Hi Klaus,

im no expert but this has worked for me

[forms]![formname].requery

hope this works for you

regards

richard

> I do have the following
>
[quoted text clipped - 32 lines]
> Thanks
> Klaus
Amateur - 21 May 2007 12:30 GMT
Do you mean:

Private Sub paymentamount_AfterUpdate()
DoCmd [Forms]![billsopenvalue].requery
End Sub

If yes, I get the error message: Expected Function or variable
Any other idea or is my code wrong?
Thanks
Klaus

> Hi Klaus,
>
[quoted text clipped - 44 lines]
> > Thanks
> > Klaus
richard harris - 21 May 2007 12:43 GMT
Hi Klaus,

there is no need for the docmd.

you could put the code in an after update event or you could have a command
button called 'Update' and put the code there.

Private Sub paymentamount_AfterUpdate()
>  [Forms]![billsopenvalue].requery
>  End Sub

hope this helps

regards

richard

> Do you mean:
>
[quoted text clipped - 55 lines]
> > > Thanks
> > > Klaus
Amateur - 21 May 2007 13:01 GMT
Dear Richard

I have now
[Forms]![customers]![billsopenvalue].Requery

It's not 100% working. If I change the field in my payments form for the
first time the form billsopenvalue is not updated immidiately. If I put
another payment into the payment form I see the up-date from the first input
- but I would like to see the update immidiately processed.
Any idea what I do wrong?
Thanks
Klaus

> Hi Klaus,
>
[quoted text clipped - 72 lines]
> > > > Thanks
> > > > Klaus
Ofer Cohen - 21 May 2007 13:16 GMT
Open the F_receivedpayments form as Dialog, so the code will pause until you
close the receivedpayments form, and then run the requery to refresh the  sub
form

Docmd.OpenForm "receivedpayments",,,,,acDialog
Me.[billsopenvalue].Requery

Signature

Good Luck
BS"D

> Dear Richard
>
[quoted text clipped - 85 lines]
> > > > > Thanks
> > > > > Klaus
Amateur - 21 May 2007 13:30 GMT
Hi Ofer
can you tell me how to open my receivedpayment form as Dialog?

> Open the F_receivedpayments form as Dialog, so the code will pause until you
> close the receivedpayments form, and then run the requery to refresh the  sub
[quoted text clipped - 92 lines]
> > > > > > Thanks
> > > > > > Klaus
Ofer Cohen - 21 May 2007 13:35 GMT
Do you have a command button  on the customers form that open receivedpayment
form?

If you do, then in the previous post there is an example how to

Signature

Good Luck
BS"D

> Hi Ofer
> can you tell me how to open my receivedpayment form as Dialog?
[quoted text clipped - 95 lines]
> > > > > > > Thanks
> > > > > > > Klaus
richard harris - 21 May 2007 13:19 GMT
Hi klaus,

you would not requery the field, just the form.  if there is a subform then
you would need to requery the subform as follows

[forms]![mainform]![subform]

a good way to add payments would be to have a command on your main form
which when clicked would open a new form to recieve the data entry.  once
entered upon closing the data entry form the main form would be requeried

(create a small form to accept the data you want, include the id number
linked to the main form)

sometihng like

private sub cmdopenform_click()

dim stdoc as string

stdoc ="the form you want to enter the data in to"

docmd.openform, stdoc, , , acnormal, acadd

end sub

this will open the form in add mode

then you need a before insert event on the form to take the id ref number
from the main form to the sub form, this will ensure the record is attached
to the correct master record

private sub your data form_beforeinsert()

With Forms![your main form]
       If Not IsNull(!your id autonumber) Then
       Me.your id autonumber= !your id autonumber
       End If
   End With
end sub

then once you have entered all your data you need to close the from, the
best thing to do is have a command to save and close with code as follows

Private Sub cmdcloseSave_Click()
On Error GoTo Err_cmdcloseSave_Click

    Dim stDocName As String
   Dim stLinkCriteria As String

   stDocName = "your main form name"
   
   stLinkCriteria = "[your id number]=" & Me![your id number]
   
   Select Case True (you can use this to ensure all fields are filled in or
ignore the case select)

   Case IsNull(your field name)
       MsgBox Prompt:="You have not entered...."

   Case IsNull(your field name)
       MsgBox Prompt:="You have not entered...."

   Case Else
 
   DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
   DoCmd.OpenForm stDocName, , , stLinkCriteria
   [Forms]![your main form].Requery
   DoCmd.Close acForm, "the name of your add data form", acSaveYes
   
   End Select
   

Exit_cmdCloseSave_Click:
   Exit Sub

Err_cmdCloseSave_Click:
   MsgBox Err.Description
   Resume Exit_cmdCloseSave_Click
   
End Sub

i hope this all makes sense and will help you achieve what you want to do.  
regards  richard

> Dear Richard
>
[quoted text clipped - 85 lines]
> > > > > Thanks
> > > > > Klaus
 
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.