Can't get combo box on subform to update.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a form with a subform on it. On the subform there is a field called
sources which is a combo box.

On double click of this field a popup form opens to allow the user to enter
a new source but no matter what i try i can't get the new entry to appear in
the box without moving forward and back a record.

I have tried requerying the subform on close of the popup i've tried putting
a requery statement in the onfocus property of the sources field itself and
various other methods.

I realise this is probably easily solved but i'm too close to it to see the
solution.

Thanks in advance for any help.
 
Hi,
once you add a new record - you have to requery combobox (it has a requery
method). you can use this in popup form close event
 
Hi

Thanks for your reply but i wrote in my original post that I had already
tried writing code in the on close event of the popup requerying the form and
the on focus event of the combo box itself and neither of these methods
worked.

Gillian
 
Timing is everything. It sounds like you are requrying the combo before the
record has been added. Put the requery code in the AfterUpdate event of the
popup form and you only need to requery the combo. Do not requery the form.
 
I would suggest that you need to requery the *combobox* at the end of
your double-click event. You don't need to requery the form.

Requerying a *Form* re-pulls the record's data from the RECORDsource (in
case something else has changed the underlying table(s) since the form's
OnCurrent event).

Requerying a *combobox* (or listbox, etc.) re-pulls data from the
ROWsource of the control (in case something has changed since the
control was loaded).

The names and actions are similar and confusing. However, it sounds
like you want some code like:


'air code
sub cmbSources_DoubleClick()
'Open popup form to change data in tblSources
docmd.OpenForm "frmSources",,,,acFormAdd,acDialog
'code pauses until frmSources is closed

'requery the Control, because its rowsource may have changed since the
previous action
'without this requery, the combobox doesn't know about
additions/edits/deletions
cboSources.Requery

End Sub

HTH,

Kevin
 
Hi

Thanks for you help i have tried as you suggested requerying the box on the
popup form but i get a really strange result.

The double click event to open the add sources popup for is on a field
called source on my continuous subform. Once i close the popup form and go
back to my main form with the record in the subform that i double clicked on
to update the sources doesn't have the new source but if i go to the record
below that in the subform it has the new entry.

Do you have any idea why this has happened.

Thanks
 
Back
Top