doCmd.Requery

G

Guest

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
 
G

Guest

Hi Klaus,

im no expert but this has worked for me

[forms]![formname].requery

hope this works for you

regards

richard
 
G

Guest

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
richard harris said:
Hi Klaus,

im no expert but this has worked for me

[forms]![formname].requery

hope this works for you

regards

richard

Amateur said:
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
 
G

Guest

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

Amateur said:
Do you mean:

Private Sub paymentamount_AfterUpdate()
[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
richard harris said:
Hi Klaus,

im no expert but this has worked for me

[forms]![formname].requery

hope this works for you

regards

richard

Amateur said:
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
 
G

Guest

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


richard harris said:
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

Amateur said:
Do you mean:

Private Sub paymentamount_AfterUpdate()
[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
richard harris said:
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

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
 
G

Guest

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

--
Good Luck
BS"D


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


richard harris said:
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

Amateur said:
Do you mean:

Private Sub paymentamount_AfterUpdate()
[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,

im no expert but this has worked for me

[forms]![formname].requery

hope this works for you

regards

richard

:

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
 
G

Guest

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



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


richard harris said:
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

Amateur said:
Do you mean:

Private Sub paymentamount_AfterUpdate()
[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,

im no expert but this has worked for me

[forms]![formname].requery

hope this works for you

regards

richard

:

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
 
G

Guest

Hi Ofer
can you tell me how to open my receivedpayment form as Dialog?

Ofer Cohen said:
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

--
Good Luck
BS"D


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


richard harris said:
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:

Private Sub paymentamount_AfterUpdate()
[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,

im no expert but this has worked for me

[forms]![formname].requery

hope this works for you

regards

richard

:

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
 
G

Guest

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

--
Good Luck
BS"D


Amateur said:
Hi Ofer
can you tell me how to open my receivedpayment form as Dialog?

Ofer Cohen said:
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

--
Good Luck
BS"D


Amateur said:
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,

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:

Private Sub paymentamount_AfterUpdate()
[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,

im no expert but this has worked for me

[forms]![formname].requery

hope this works for you

regards

richard

:

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
 

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