Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh control on a form 1

Status
Not open for further replies.

bdm1

Programmer
Feb 4, 2002
75
US
How can I update a combo control on a form to reflect the latest value entered in another form?

I have a payment form which updates the subscribers form on the afterupdate event. The only control which updates is the paidthrough control. I need to also have the payment type update. I have included the code on the Payment Form. You will note that not all payment types are considered. What am I doing wrong? Is the problem because it is a combo box? If so, how to fix? Thanks...

Private Sub Form_BeforeUpdate(Cancel As Integer)

' Check to make sure a payment type (individual, family etc.) is selected, then update
' the PaidThrough field (in the Subscribers table)


Dim bytMonths As Byte
'Dim PaymentType As Variant

If PaymentType = 0 Then
DisplayMessage "You must select a payment type."

'Return to the subscriber form and do not save the payment entry.

Cancel = True
Exit Sub
End If

'If this payment is for more than 1 year, multiply by 12 to calculate the
'new paid through date.

bytMonths = YearsPaid * 12

'Keep a going and

Select Case PaymentType

'do not include misc, building fund and any other payment
'type not directly related to membership dues.

Case 22, 23, 24, 25, 26
If IsNull(PaidThrough) Or PaidThrough < Date Then

' If this is the first payment, or the the paid through date
'is before today's date, meaning the membership has lapsed
'set PaidThrough date 12 months from CURRENT date.


PaidThrough = DateSerial(Year(Date), Month(Date) + bytMonths, 1)

Else

' Otherwise, add additional months to the EXISTING PaidThrough value.

PaidThrough = DateSerial(Year(PaidThrough), Month(PaidThrough) + _
bytMonths, 1)
PaymentType = PaymentType
End If
'Continue to ignore non-membership related payments

Case 27, 28, 29
Exit Sub
Case Else
End Select



End Sub

Private Sub Form_AfterUpdate()
' Update other forms if they are open.


If IsOpen("Subscribers") Then
' Refresh the Subscribers form to show
' the new PaidThrough value.

Forms!Subscribers.Refresh

End If
If IsOpen("PaymentHistory") Then
' Requery the PaymentHistory pop-up form
' to show the new payment.

Forms!PaymentHistory.Requery


End If

End Sub

 
have you tried calling the requery method of the combobox to update it? this will work once the new information has been entered on the second form. following syntax:

Forms!Formname.comboboxname.requery
 
Thanks for the response and yes I did attempt the requery method with no luck. Perhaps I am doing it wrong.. I have it on the after update event of the payment form.

Forms!Subscribers.PaymentType.Requery

There must be a way to update this combo box.........
 
try placing the code in the after_insert event of the payment form.... that might work, if not something very odd is going on. And the combobox rowsource is a query based on the table that is being updated in the payment form?
 
Hello again, tried your suggestion and still no luck....The row source for this combo is from the payment type table. The data source for the payment form is from the payment table and the data source for the subscriber form is from the subscriber table. Do you think that if I change the combo box paymentType on the subscriber form to a text box that would work? After all, I want it updateable from the payment form only. Thanks...
 
hmmm, but then you wouldn't be able to have a list being displayed. If you wanted you could email the zipped db to me, jtseleie@theedge.ca Its usually easier to have a look firsthand.
 
Did you get it to work, I think I am having the same problem you are having.
 
Hi Tomcone, I have not solved the puzzle yet, nor have I had the time to delve into the problem further. I did get the payment type to update on the subscriber form from the payment form, but it is updating all the payment types and not selecting those from the select case statement. I'm sure it's syntax related. Since this is a volunteer project for a non-profit org. I have not had the time to devote to solving this problem expeditiously. Must get back to it soon....What problem were you challenged with?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top