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" wrote:
> 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" wrote:
>
> > 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" wrote:
> >
> > > 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" wrote:
> > >
> > > > Hi Klaus,
> > > >
> > > > im no expert but this has worked for me
> > > >
> > > > [forms]![formname].requery
> > > >
> > > > hope this works for you
> > > >
> > > > regards
> > > >
> > > > richard
> > > >
> > > > "Amateur" wrote:
> > > >
> > > > > 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
> > > > >
|