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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform not reflecting new record created by listbox selection

Status
Not open for further replies.

DMBLuva

Technical User
Jul 16, 2008
27
0
0
US
Hi all,
I'm sure there is a simple solution to this (isn't there always?), but I have yet to find it. I have a main form that has a listbox containing records linking to main form. In the main form I have a subform that builds on the listbox actually LINKING the record to the mainform's record. Following me?

So I'm using this listbox to enter a new record in a link table based on the selection in the listbox to the mainform's record. Based on that link table the subform should now be showing the record that was once in the listbox and is now meeting the criteria of the subform. Sorry long day so I hope I not losing you.

Ok so all works great and I get the record into the link table based on the selection of the record in the listbox, however I requery the subform and poof...it doesn't show. In fact, if you look on the recordsource query of the form the new record shows. At first I thought it was because I was using a groupby query, so I changed it and no that wasn't it. I've checked the allow additions, edits, etc and they are all to yes. Data entry is set to no.
I'm on a deadline so any help you can give would be great!

code for entry of record:
Answer = MsgBox("Are you sure you want to apply this invoice to the current expenditure?", vbCritical + vbOKCancel)
If Answer = vbOK Then
For Each varitem In Me.lstInvoices.ItemsSelected
rs.AddNew
rs!ExpenditureID = Me.ExpenditureID.Value
rs!InvoiceID = Me.lstInvoices.Column(0, varitem)
rs!ExpendedAmount = Paidout
rs.Update
Next

Me.New_Invoice_to_Expenditure.Requery
Me.RemainingBalance.Requery
'requery listbox
Me.lstInvoices.Requery
'requery subform
Me.txtremainingbalance.Requery
'refresh main form
Me.Form.Refresh
Else
Exit Sub
End If

ErrExit:
Exit Sub
 
I solved it. It had to do with the child and master links. I had to remove them in order for the subform to be refreshed to show the new records. See, something simple!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top